|
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -43,14 +44,23 @@ public class SyncBasicFileImpl implements ISyncBasicFileService {
|
|
|
|
|
List<BasicInfo> basicInfos = pictureMapper.getBasicInfoList();
|
|
|
|
|
//2.代入到联众数据库 查询图片信息
|
|
|
|
|
//3.根据id查询出文件信息
|
|
|
|
|
|
|
|
|
|
for (BasicInfo basicInfo: basicInfos) {
|
|
|
|
|
|
|
|
|
|
List<Tscan> oldScanList = tscanMapper.getOldScanListByPid(basicInfo.getPatientId());
|
|
|
|
|
//4.文件数据同步-> 路径 病案号 +病案id主键
|
|
|
|
|
List<Tscan> syncScanList = this.doSyncFile(basicInfo);
|
|
|
|
|
List<Tscan> insertList = this.getInsertList(oldScanList,syncScanList);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(insertList)){
|
|
|
|
|
//5.数据入库tsacn
|
|
|
|
|
tscanMapper.insertScanList(insertList);
|
|
|
|
|
//判断数据量 如果文件数据大于五百条 需要做拆分分批次插入
|
|
|
|
|
int batchSize = 100;
|
|
|
|
|
// 拆分列表
|
|
|
|
|
for (int i = 0; i < insertList.size(); i += batchSize) {
|
|
|
|
|
int endIndex = Math.min(i + batchSize, insertList.size());
|
|
|
|
|
List<Tscan> sublist = insertList.subList(i, endIndex);
|
|
|
|
|
//5.数据入库tsacn
|
|
|
|
|
tscanMapper.insertScanList(sublist);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.success("同步成功");
|
|
|
|
@ -69,22 +79,30 @@ public class SyncBasicFileImpl implements ISyncBasicFileService {
|
|
|
|
|
|
|
|
|
|
private List<Tscan> doSyncFile(BasicInfo basicInfo) {
|
|
|
|
|
List<Tscan> tscanList = new ArrayList<>(1000);
|
|
|
|
|
//010 00 09590 19990405
|
|
|
|
|
|
|
|
|
|
String[] disDate = dateFormat.format(basicInfo.getDisDate()).split("-");
|
|
|
|
|
String cyYear = disDate[0];
|
|
|
|
|
String cyMonth = disDate[1];
|
|
|
|
|
String cyDay = disDate[2];
|
|
|
|
|
String inpatientNo = basicInfo.getInpatientNo();
|
|
|
|
|
String patPath = basicInfo.getPatPath();
|
|
|
|
|
String inpatientNo = basicInfo.getInpatientNo().trim();
|
|
|
|
|
|
|
|
|
|
String patientId = basicInfo.getPatientId();
|
|
|
|
|
String pid = basicInfo.getId();
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String rootDir = "E:\\ServerE01"+File.separator
|
|
|
|
|
+cyYear+File.separator
|
|
|
|
|
+cyYear+cyMonth+ File.separator
|
|
|
|
|
+cyYear+cyMonth+cyDay+ File.separator
|
|
|
|
|
+"010"+inpatientNo+cyYear+cyMonth+cyDay+File.separator;
|
|
|
|
|
+patPath+File.separator;
|
|
|
|
|
|
|
|
|
|
String outDir = "E:\\docus"+File.separator+inpatientNo+File.separator+pid ;
|
|
|
|
|
String outDir = "E:\\docus"+File.separator+inpatientNo+File.separator+patientId ;
|
|
|
|
|
|
|
|
|
|
File file = new File(rootDir);
|
|
|
|
|
if (!file.exists()){
|
|
|
|
|
rootDir= basicInfo.getHostReason();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2.根据cid查询联众表t_picture 走索引大概零点几秒
|
|
|
|
@ -114,9 +132,10 @@ public class SyncBasicFileImpl implements ISyncBasicFileService {
|
|
|
|
|
|
|
|
|
|
// 2.4组合文件信息
|
|
|
|
|
Tscan tscan = new Tscan();
|
|
|
|
|
tscan.setPatientId(pid);
|
|
|
|
|
tscan.setPatientId(patientId);
|
|
|
|
|
tscan.setAssortId(tpicture.getPicKind());
|
|
|
|
|
tscan.setScanPage(picName+".jpg");
|
|
|
|
|
tscan.setUpDate(new Date());
|
|
|
|
|
|
|
|
|
|
if (savePicFlag&&rotateFlag){
|
|
|
|
|
tscan.setUpState(200);
|
|
|
|
@ -129,6 +148,10 @@ public class SyncBasicFileImpl implements ISyncBasicFileService {
|
|
|
|
|
|
|
|
|
|
tscanList.add(tscan);
|
|
|
|
|
|
|
|
|
|
if (!savePicFlag){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|