初始化

master
linjj 1 month ago
parent a1f5cc5410
commit e54404474c

@ -36,4 +36,14 @@ public class LzRmController {
return ResultBody.success("失败");
}
@ResponseBody
@RequestMapping(value = "batch", method = RequestMethod.POST)
@ApiOperation(value = "生成目录", notes = "生成目录")
public ResultBody Batch(){
lzRmService.Batch();
return ResultBody.success("完成");
}
}

@ -0,0 +1,34 @@
package com.example.duplicate.controller.vo;
import lombok.Data;
import java.util.Date;
/**
* @ClassName Commomtable
* @Description
* @Author linjj
* @Date 2025/11/5 12:00
* @Version 1.0
*/
@Data
public class Commomtable {
//主键id
private String patientId;
//盘号
private String ph;
//病案号
private String inpatientNo;
//住院次数
private String admissTimes;
//姓名
private String name;
//出院日期
private Date disDate;
//出院科室
private String disDept;
//旧病案号
private String oldInpatientNo;
//文件路径
private String filePath;
}

@ -1,10 +1,7 @@
package com.example.duplicate.infrastructure.configOneDao;
import com.example.duplicate.controller.vo.AddLzRmCommVo;
import com.example.duplicate.controller.vo.CommomtableCopyVo;
import com.example.duplicate.controller.vo.CommomtableVo;
import com.example.duplicate.controller.vo.PageCountVo;
import com.example.duplicate.controller.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -32,4 +29,11 @@ public interface CommomtableMapper {
List<CommomtableCopyVo>com();
/**
*
* @param list
* @return
*/
int insertBatch(@Param("list") List<Commomtable> list);
}

@ -10,4 +10,6 @@ package com.example.duplicate.service;
public interface LzRmService {
int LzRmSplit();
void Batch();
}

@ -14,8 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -43,6 +45,9 @@ public class LzRmServiceImpl implements LzRmService {
private static SimpleDateFormat inSDF = new SimpleDateFormat("yyyy.mm.dd");
private static SimpleDateFormat outSDF = new SimpleDateFormat("yyyy-mm-dd");
/* 日期解析工具 */
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
@Override
public int LzRmSplit() {
//新增状态
@ -78,6 +83,47 @@ public class LzRmServiceImpl implements LzRmService {
return addStatic;
}
@Override
public void Batch() {
File root = new File("D:/tmp");
File[] firstLevelFolders = root.listFiles(File::isDirectory);
if (firstLevelFolders == null) return;
for (File folder : firstLevelFolders) {
List<Commomtable> batch = new ArrayList<>();
File[] subFolders = folder.listFiles(File::isDirectory);
if (subFolders == null) continue;
for (int i = 0; i < subFolders.length; i++) {
File sub = subFolders[i];
String[] p = sub.getName().split("-", -1);
Commomtable c = new Commomtable();
c.setPatientId(new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new java.util.Date())+ String.format("%03d", i));
c.setPh(seg(p, 0)); // 盘号
c.setInpatientNo(seg(p, 1)); // 病案号
c.setAdmissTimes(seg(p, 2));
c.setName(seg(p, 3));
c.setDisDate(parseDate(seg(p, 4)));
c.setDisDept(seg(p, 5));
c.setOldInpatientNo(seg(p, 6));
c.setFilePath(sub.getAbsolutePath());
batch.add(c);
}
/* 模拟批量新增:这里只是打印,实际可调用 Mapper/DAO 批量插入 */
System.out.println(">>> 准备批量插入一级文件夹:" + folder.getName()
+ ",共 " + batch.size() + " 条");
batch.forEach(System.out::println);
commomtableMapper.insertBatch(batch);
// TODO: 调用 service.batchInsert(batch);
File newDir = new File(folder.getParent(), folder.getName() + "-1");
}
}
/**
* @description: Archive_Master
* @params: commomtableCopyVo
@ -190,4 +236,18 @@ public class LzRmServiceImpl implements LzRmService {
return outDate;
}
/* 辅助:缺段补“无” */
private static String seg(String[] arr, int i) {
return i < arr.length && !arr[i].isEmpty() ? arr[i] : "无";
}
/* 辅助:解析日期,失败给 null */
private static Date parseDate(String src) {
if ("无".equals(src)) return null;
try {
return SDF.parse(src);
} catch (ParseException e) {
return null;
}
}
}

@ -18,15 +18,15 @@ spring:
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# type: com.alibaba.druid.pool.DruidDataSource
db1: #数据源1
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=zj_record_new
jdbc-url: jdbc:sqlserver://192.168.2.22:1433;DatabaseName=qf_record_lin
username: sa
password: admin123
password: 123456
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
db2: #数据源2
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=qf_record
jdbc-url: jdbc:sqlserver://192.168.2.22:1433;DatabaseName=gzsrm
username: sa
password: admin123
password: 123456
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource
#加快springboot初始化延缓初始化加载

@ -8,6 +8,23 @@
ph, gdh,splitName)
values (#{patientId}, #{admissId}, #{admissTimes}, #{inpatientNo}, #{name}, #{disDate}, #{disDeptName}, #{ph},#{gdh},#{splitName})
</insert>
<!-- 批量插入 -->
<insert id="insertBatch">
INSERT INTO common_table
(patient_id, inpatient_no, admiss_times, name, dis_date, dis_dept, old_inpatient_no, file_path,ph)
VALUES
<foreach collection="list" item="c" separator=",">
(#{c.patientId},
#{c.inpatientNo},
#{c.admissTimes},
#{c.name},
#{c.disDate},
#{c.disDept},
#{c.oldInpatientNo},
#{c.filePath},
#{c.ph})
</foreach>
</insert>
<select id="getZdAssort" resultType="com.example.duplicate.controller.vo.CommomtableVo">
SELECT

@ -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.QualityMapper;
import lombok.extern.slf4j.Slf4j;
@ -23,8 +25,10 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.imageio.ImageIO;
@ -35,107 +39,62 @@ import javax.imageio.ImageIO;
@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;
private static CommomtableMapper commomtableMapper;
/* 日期解析工具 */
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
@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);
}
public static void main(String[] args) throws ParseException {
File root = new File("D:/tmp");
}
File[] firstLevelFolders = root.listFiles(File::isDirectory);
if (firstLevelFolders == null) return;
for (File folder : firstLevelFolders) {
List<Commomtable> batch = new ArrayList<>();
@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);
}
}
}
File[] subFolders = folder.listFiles(File::isDirectory);
if (subFolders == null) continue;
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) {
List<String> jpgPath = new ArrayList<>();
List<Path> imgPaths=new ArrayList<>();
File directory = new File(directoryPath);
Commomtable c = new Commomtable();
c.setPatientId(new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new java.util.Date())+ String.format("%03d", i));
c.setInpatientNo(seg(p, 0));
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());
// 遍历目录
File[] files = directory.listFiles((dir, name) -> name.toLowerCase().matches(".*\\.(jpg)$"));
if (files != null) {
for (File file : files) {
if (file.isFile()) {
jpgPath.add(file.getAbsolutePath());
}
batch.add(c);
}
}
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("-"));
/* 模拟批量新增:这里只是打印,实际可调用 Mapper/DAO 批量插入 */
System.out.println(">>> 准备批量插入一级文件夹:" + folder.getName()
+ ",共 " + batch.size() + " 条");
batch.forEach(System.out::println);
// TODO: 调用 service.batchInsert(batch);
File newDir = new File(folder.getParent(), folder.getName() + "-1");
}
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);
/* 辅助:缺段补“无” */
private static String seg(String[] arr, int i) {
return i < arr.length && !arr[i].isEmpty() ? arr[i] : "无";
}
public static String bytesToHexString(byte[] src) {
StringBuilder stringBuilder = new StringBuilder();
if (src == null || src.length <= 0) {
/* 辅助:解析日期,失败给 null */
private static Date parseDate(String src) {
if ("无".equals(src)) return null;
try {
return SDF.parse(src);
} catch (ParseException e) {
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();
}
}

Loading…
Cancel
Save