You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.4 KiB
Java
142 lines
4.4 KiB
Java
package com.example;
|
|
|
|
|
|
|
|
|
|
import com.example.duplicate.infrastructure.configOneDao.MidMapper;
|
|
import com.example.duplicate.infrastructure.configOneDao.QualityMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.ofdrw.converter.ofdconverter.ImageConverter;
|
|
import org.ofdrw.layout.OFDDoc;
|
|
import org.ofdrw.layout.PageLayout;
|
|
import org.ofdrw.layout.element.Img;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@SpringBootTest(classes = com.example.SpringbootDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
@Slf4j
|
|
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
|
|
MidMapper midMapper;
|
|
|
|
|
|
@Test
|
|
public void getPic() {
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
public void ImageConverterTest() throws IOException {
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static List<Path> findImageFiles(String directoryPath) {
|
|
List<String> jpgPath = new ArrayList<>();
|
|
List<Path> imgPaths=new ArrayList<>();
|
|
File directory = new File(directoryPath);
|
|
|
|
// 遍历目录
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
public void intercept() {
|
|
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() {
|
|
String a = "0000000002";
|
|
String s = String.format("%010d", Integer.parseInt(a));
|
|
System.out.println("s:" + s);
|
|
}
|
|
|
|
|
|
public static String bytesToHexString(byte[] src) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (src == null || src.length <= 0) {
|
|
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();
|
|
}
|
|
|
|
|
|
}
|