|
|
|
@ -10,18 +10,24 @@ import net.coobird.thumbnailator.Thumbnails;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileReader;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
@ -37,6 +43,8 @@ public class UpdateService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private DataQuery dataQuery;
|
|
|
|
|
|
|
|
|
|
private Set<String> lianZhongPatPicDirs = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
public List<CardInfo> updateData() {
|
|
|
|
|
List<CardInfo> cardInfos = dataQuery.dateQuery();
|
|
|
|
|
dataQuery.updateBatchState(cardInfos, 1);
|
|
|
|
@ -49,6 +57,7 @@ public class UpdateService {
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
|
public void upload() {
|
|
|
|
|
initLianZhongPatPicDir();
|
|
|
|
|
log.info("联众同步数据启动>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
|
String syncDir = FilePathUtil.currentPath() + File.separator + "lianzhong-sync";
|
|
|
|
|
FilePathUtil.mkdirs(syncDir);
|
|
|
|
@ -128,8 +137,7 @@ public class UpdateService {
|
|
|
|
|
fileInfo.setFileTitle(picture.getPicname());
|
|
|
|
|
fileInfo.setUploadFileName(pictureFile.getName());
|
|
|
|
|
fileInfo.setAssortId(picture.getPickind());
|
|
|
|
|
// todo 应该有个排序
|
|
|
|
|
fileInfo.setSort(0);
|
|
|
|
|
fileInfo.setSort(picture.getPicno());
|
|
|
|
|
fileInfos.add(fileInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,7 +174,7 @@ public class UpdateService {
|
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
|
String s = new Gson().toJson(uploadInfo);
|
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(batch, "http://192.168.161.102:9511/lianzhong/batchFileUploadJpg", params);
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(batch, "http://129.7.1.25:9511/lianzhong/batchFileUploadJpg", params);
|
|
|
|
|
boolean res = commonResult.getCode() == 0;
|
|
|
|
|
success = success && res;
|
|
|
|
|
}
|
|
|
|
@ -175,7 +183,7 @@ public class UpdateService {
|
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
|
String s = new Gson().toJson(uploadInfo);
|
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/lianzhong/batchFileUploadJpg", params);
|
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://129.7.1.25:9511/lianzhong/batchFileUploadJpg", params);
|
|
|
|
|
success = commonResult.getCode() == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -217,16 +225,113 @@ public class UpdateService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
UpdateService updateService = new UpdateService();
|
|
|
|
|
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirs));
|
|
|
|
|
updateService.initLianZhongPatPicDir();
|
|
|
|
|
System.out.println(new Gson().toJson(updateService.lianZhongPatPicDirs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initLianZhongPatPicDir() {
|
|
|
|
|
log.info(">>>>>>>>>>>>初始化联众患者文件目录");
|
|
|
|
|
String readFilePath = FilePathUtil.currentPath() + File.separator + "lianzhong-patpic-dir.txt";
|
|
|
|
|
File readFile = new File(readFilePath);
|
|
|
|
|
if (readFile.exists()) {
|
|
|
|
|
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(readFile))) {
|
|
|
|
|
String line;
|
|
|
|
|
while ((line = bufferedReader.readLine()) != null) {
|
|
|
|
|
lianZhongPatPicDirs.add(line);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(">>>>>>>>>>>> 初始化联众患者文件目录读取存储文件错误!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<String> rootDirs = Arrays.asList("D:\\UnionNet\\ServerD", "D:\\UnionNet\\ServerD_ny", "D:\\UnionNet\\ServerDTemp",
|
|
|
|
|
"G:\\UnionNet\\ServerD", "G:\\UnionNet\\ServerD_ny", "G:\\UnionNet\\ServerDTemp");
|
|
|
|
|
for (String rootDir : rootDirs) {
|
|
|
|
|
File rootDirFile = new File(rootDir);
|
|
|
|
|
if (!rootDirFile.exists()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 第一层 年 ,如果有,后面基本都会有
|
|
|
|
|
File[] level1 = rootDirFile.listFiles();
|
|
|
|
|
if (level1 == null || level1.length <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (File level1File : level1) {
|
|
|
|
|
// 第二层 年月
|
|
|
|
|
File[] level2 = level1File.listFiles();
|
|
|
|
|
if (level2 == null || level2.length <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (File level2File : level2) {
|
|
|
|
|
if (level2File.isDirectory()) {
|
|
|
|
|
// 第三层 年月日
|
|
|
|
|
File[] level3 = level2File.listFiles();
|
|
|
|
|
if (level3 == null || level3.length <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (File level3File : level3) {
|
|
|
|
|
if (level3File.isDirectory()) {
|
|
|
|
|
// 第四层,患者存放文件的最后一级目录
|
|
|
|
|
File[] level4 = level3File.listFiles();
|
|
|
|
|
if (level4 == null || level4.length <= 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (File level4File : level4) {
|
|
|
|
|
if (level4File.isDirectory()) {
|
|
|
|
|
lianZhongPatPicDirs.add(level4File.getPath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!lianZhongPatPicDirs.isEmpty()) {
|
|
|
|
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(readFile));) {
|
|
|
|
|
for (String picDir : lianZhongPatPicDirs) {
|
|
|
|
|
writer.write(picDir);
|
|
|
|
|
writer.newLine();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error("持久化联众患者文件目录错误:" + ex.getMessage(), ex);
|
|
|
|
|
if (readFile.exists()) {
|
|
|
|
|
readFile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LianZhongUploadInfo.PatientInfo convert(CardInfo cardInfo) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
LianZhongUploadInfo.PatientInfo patientInfo = new LianZhongUploadInfo.PatientInfo();
|
|
|
|
|
// todo 病案号
|
|
|
|
|
patientInfo.setInpatientNo(null);
|
|
|
|
|
// todo 住院次数
|
|
|
|
|
patientInfo.setAdmissTimes(null);
|
|
|
|
|
patientInfo.setInpatientNo(cardInfo.getPatno());
|
|
|
|
|
String gestno = cardInfo.getGestno();
|
|
|
|
|
// 123步设置住院次数
|
|
|
|
|
Integer admissTimes = cardInfo.getPatnum();
|
|
|
|
|
if (admissTimes == null && StringUtils.hasText(gestno)) {
|
|
|
|
|
try {
|
|
|
|
|
String admissTimesStr = removeLeadingZeros(gestno.substring(gestno.length() - 3));
|
|
|
|
|
admissTimes = Integer.valueOf(admissTimesStr);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error("无法解析gestno:{} 当中的住院次数!", gestno);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 没办法获取那就直接用出院的日期当住院次数
|
|
|
|
|
if (admissTimes == null) {
|
|
|
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
admissTimes = Integer.valueOf(sdf2.format(cardInfo.getOutdate()));
|
|
|
|
|
}
|
|
|
|
|
patientInfo.setAdmissTimes(admissTimes);
|
|
|
|
|
patientInfo.setAge(cardInfo.getPatage());
|
|
|
|
|
patientInfo.setName(cardInfo.getPatname());
|
|
|
|
|
// todo 年龄
|
|
|
|
|
patientInfo.setSex("") ;
|
|
|
|
|
|
|
|
|
|
patientInfo.setSex("1".equals(cardInfo.getPatsex()) ? "男" : "女");
|
|
|
|
|
patientInfo.setSexName("");
|
|
|
|
|
patientInfo.setAdmissDate(cardInfo.getIndate() == null ? null : sdf.format(cardInfo.getIndate()));
|
|
|
|
|
patientInfo.setDisDate(cardInfo.getOutdate() == null ? null : sdf.format(cardInfo.getOutdate()));
|
|
|
|
@ -243,41 +348,20 @@ public class UpdateService {
|
|
|
|
|
private String findLianZhongDir(CardInfo cardInfo) {
|
|
|
|
|
String gestno = cardInfo.getGestno();
|
|
|
|
|
String patno = cardInfo.getPatno();
|
|
|
|
|
Date outdate = cardInfo.getOutdate();
|
|
|
|
|
SimpleDateFormat yearSdf = new SimpleDateFormat("yyyy");
|
|
|
|
|
SimpleDateFormat yearMonthSdf = new SimpleDateFormat("yyyyMM");
|
|
|
|
|
SimpleDateFormat yearMonthDaySdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
String yFormat = yearSdf.format(outdate);
|
|
|
|
|
String ymFormat = yearMonthSdf.format(outdate);
|
|
|
|
|
String ymdFormat = yearMonthDaySdf.format(outdate);
|
|
|
|
|
List<String> archiveDirs = Arrays.asList(
|
|
|
|
|
"D:\\UnionNet\\ServerD",
|
|
|
|
|
"D:\\UnionNet\\ServerD_ny",
|
|
|
|
|
"D:\\UnionNet\\ServerDTemp",
|
|
|
|
|
"G:\\UnionNet\\ServerD",
|
|
|
|
|
"G:\\UnionNet\\ServerD_ny",
|
|
|
|
|
"G:\\UnionNet\\ServerDTemp");
|
|
|
|
|
for (String archiveDir : archiveDirs) {
|
|
|
|
|
String ymdDateDir = archiveDir + File.separator + yFormat + File.separator + ymFormat + File.separator + ymdFormat;
|
|
|
|
|
File ymdDateDirFile = new File(ymdDateDir);
|
|
|
|
|
if (!ymdDateDirFile.exists()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
File[] patPicDirs = ymdDateDirFile.listFiles();
|
|
|
|
|
if (patPicDirs != null && patPicDirs.length > 0) {
|
|
|
|
|
for (File patPicDir : patPicDirs) {
|
|
|
|
|
String dirName = patPicDir.getName();
|
|
|
|
|
for (String lianZhongPatPicDir : lianZhongPatPicDirs) {
|
|
|
|
|
String dirName = new File(lianZhongPatPicDir).getName();
|
|
|
|
|
String comparePart = dirName.substring(2).substring(0, 10);
|
|
|
|
|
comparePart = removeLeadingZeros(comparePart);
|
|
|
|
|
//TODO gestno 或者 patno 进行 识别
|
|
|
|
|
boolean match = comparePart.contains(removeLeadingZeros(patno));
|
|
|
|
|
if (match) {
|
|
|
|
|
return patPicDir.getPath();
|
|
|
|
|
// gestno 或者 patno 进行 识别
|
|
|
|
|
if (StringUtils.hasText(gestno)) {
|
|
|
|
|
if (comparePart.contains(removeLeadingZeros(gestno))) {
|
|
|
|
|
return lianZhongPatPicDir;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (comparePart.contains(removeLeadingZeros(patno))) {
|
|
|
|
|
return lianZhongPatPicDir;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|