|
|
|
@ -3,6 +3,8 @@ package com.example;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.duplicate.controller.vo.Commomtable;
|
|
|
|
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.CommomtableMapper;
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.MidMapper;
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.MidMapper;
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.QualityMapper;
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.QualityMapper;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -23,8 +25,10 @@ import java.io.FileInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
@ -35,107 +39,62 @@ import javax.imageio.ImageIO;
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class DemoApplicationTests {
|
|
|
|
public class DemoApplicationTests {
|
|
|
|
|
|
|
|
|
|
|
|
private static SimpleDateFormat inSDF = new SimpleDateFormat("yyyy.mm.dd");
|
|
|
|
|
|
|
|
private static SimpleDateFormat outSDF = new SimpleDateFormat("yyyy-mm-dd");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
QualityMapper qualityMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
MidMapper midMapper;
|
|
|
|
private static CommomtableMapper commomtableMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 日期解析工具 */
|
|
|
|
|
|
|
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public static void main(String[] args) throws ParseException {
|
|
|
|
public void getPic() {
|
|
|
|
File root = new File("D:/tmp");
|
|
|
|
List<String> mid = midMapper.getMid();
|
|
|
|
|
|
|
|
String curl = " curl -X POST http://10.36.116.108:3391/makeUp/makeUpPacsByMasterId -d";
|
|
|
|
|
|
|
|
String param = "masterId=";
|
|
|
|
|
|
|
|
for (String masterId:mid){
|
|
|
|
|
|
|
|
log.info(curl+" "+param+masterId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
File[] firstLevelFolders = root.listFiles(File::isDirectory);
|
|
|
|
|
|
|
|
if (firstLevelFolders == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (File folder : firstLevelFolders) {
|
|
|
|
|
|
|
|
List<Commomtable> batch = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
File[] subFolders = folder.listFiles(File::isDirectory);
|
|
|
|
public void ImageConverterTest() throws IOException {
|
|
|
|
if (subFolders == null) continue;
|
|
|
|
String directoryPath = "D:\\tmp1\\004624"; // 替换为你的目录路径
|
|
|
|
|
|
|
|
List<Path> imagePaths = findImageFiles(directoryPath);
|
|
|
|
|
|
|
|
for (int i=0;i<imagePaths.size();i++){
|
|
|
|
|
|
|
|
try(ImageConverter converter= new ImageConverter(Paths.get("D:\\tmp1\\ofd\\"+i+".ofd"))) {
|
|
|
|
|
|
|
|
BufferedImage bufferedImage = ImageIO.read(imagePaths.get(i).toFile());
|
|
|
|
|
|
|
|
double imageHeight = bufferedImage.getHeight();
|
|
|
|
|
|
|
|
double imageWidth = bufferedImage.getWidth();
|
|
|
|
|
|
|
|
double scale = PageLayout.A4().getWidth() / imageWidth;
|
|
|
|
|
|
|
|
double height = imageHeight * scale;
|
|
|
|
|
|
|
|
PageLayout pageLayout=new PageLayout(PageLayout.A4().getWidth(),height);
|
|
|
|
|
|
|
|
converter.setPageSize(pageLayout);
|
|
|
|
|
|
|
|
converter.append(imagePaths.get(i),PageLayout.A4().getWidth(), height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < subFolders.length; i++) {
|
|
|
|
|
|
|
|
File sub = subFolders[i];
|
|
|
|
|
|
|
|
String[] p = sub.getName().split("-", -1);
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Path> findImageFiles(String directoryPath) {
|
|
|
|
Commomtable c = new Commomtable();
|
|
|
|
List<String> jpgPath = new ArrayList<>();
|
|
|
|
c.setPatientId(new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new java.util.Date())+ String.format("%03d", i));
|
|
|
|
List<Path> imgPaths=new ArrayList<>();
|
|
|
|
c.setInpatientNo(seg(p, 0));
|
|
|
|
File directory = new File(directoryPath);
|
|
|
|
c.setAdmissTimes(seg(p, 1));
|
|
|
|
|
|
|
|
c.setName(seg(p, 2));
|
|
|
|
|
|
|
|
c.setDisDate(parseDate(seg(p, 3)));
|
|
|
|
|
|
|
|
c.setDisDept(seg(p, 4));
|
|
|
|
|
|
|
|
c.setOldInpatientNo(seg(p, 5));
|
|
|
|
|
|
|
|
c.setFilePath(sub.getAbsolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历目录
|
|
|
|
batch.add(c);
|
|
|
|
File[] files = directory.listFiles((dir, name) -> name.toLowerCase().matches(".*\\.(jpg)$"));
|
|
|
|
|
|
|
|
if (files != null) {
|
|
|
|
|
|
|
|
for (File file : files) {
|
|
|
|
|
|
|
|
if (file.isFile()) {
|
|
|
|
|
|
|
|
jpgPath.add(file.getAbsolutePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String path:jpgPath){
|
|
|
|
|
|
|
|
imgPaths.add(Paths.get(path));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return imgPaths;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 模拟批量新增:这里只是打印,实际可调用 Mapper/DAO 批量插入 */
|
|
|
|
|
|
|
|
System.out.println(">>> 准备批量插入一级文件夹:" + folder.getName()
|
|
|
|
|
|
|
|
+ ",共 " + batch.size() + " 条");
|
|
|
|
|
|
|
|
batch.forEach(System.out::println);
|
|
|
|
@Test
|
|
|
|
// TODO: 调用 service.batchInsert(batch);
|
|
|
|
public void intercept() {
|
|
|
|
File newDir = new File(folder.getParent(), folder.getName() + "-1");
|
|
|
|
String pageNumber = "66";
|
|
|
|
|
|
|
|
//如果包含--就截取--前
|
|
|
|
|
|
|
|
if (pageNumber.contains("--")) {
|
|
|
|
|
|
|
|
pageNumber = pageNumber.substring(0, pageNumber.indexOf("--"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//如果包含--就截取-前
|
|
|
|
|
|
|
|
if (pageNumber.contains("-")) {
|
|
|
|
|
|
|
|
pageNumber = pageNumber.substring(0, pageNumber.indexOf("-"));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("pageNumber:" + pageNumber);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
/* 辅助:缺段补“无” */
|
|
|
|
public void intercept1() {
|
|
|
|
private static String seg(String[] arr, int i) {
|
|
|
|
String a = "0000000002";
|
|
|
|
return i < arr.length && !arr[i].isEmpty() ? arr[i] : "无";
|
|
|
|
String s = String.format("%010d", Integer.parseInt(a));
|
|
|
|
|
|
|
|
System.out.println("s:" + s);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 辅助:解析日期,失败给 null */
|
|
|
|
public static String bytesToHexString(byte[] src) {
|
|
|
|
private static Date parseDate(String src) {
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
if ("无".equals(src)) return null;
|
|
|
|
if (src == null || src.length <= 0) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
return SDF.parse(src);
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < src.length; i++) {
|
|
|
|
|
|
|
|
int v = src[i] & 0xFF;
|
|
|
|
|
|
|
|
String hv = Integer.toHexString(v);
|
|
|
|
|
|
|
|
if (hv.length() < 2) {
|
|
|
|
|
|
|
|
stringBuilder.append(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stringBuilder.append(hv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return stringBuilder.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|