|
|
@ -69,83 +69,134 @@ public class LianZhongSyncController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void sync(CardInfo cardInfo) throws IOException {
|
|
|
|
@ApiOperation(value = "根据病案号和出院日期(yyyy-MM-dd),更新联众文件数据状态为0 ,需要重新同步 ")
|
|
|
|
String uniUrl = "http://192.168.8.74";
|
|
|
|
@GetMapping("/updateState/byInpNoAndDisDate")
|
|
|
|
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
|
|
|
|
public CommonResult<String> updateStateByInpNoAndDisDate(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("disDate") String disDate) {
|
|
|
|
if (pictures == null || pictures.size() == 0) {
|
|
|
|
try {
|
|
|
|
//如果是空的则不同步
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
dataQuery.updateBatchState(cardInfo, 5);
|
|
|
|
List<CardInfo> cardInfos = dataQuery.dateQueryByInpNo(inpatientNo);
|
|
|
|
return;
|
|
|
|
CardInfo cardInfo = null;
|
|
|
|
|
|
|
|
for (CardInfo info : cardInfos) {
|
|
|
|
|
|
|
|
if (disDate.equals(sdf.format(info.getOutdate()))) {
|
|
|
|
|
|
|
|
cardInfo = info;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Objects.isNull(cardInfo)) {
|
|
|
|
|
|
|
|
return CommonResult.failed("未找到 cardInfo 信息!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dataQuery.updateBatchState(cardInfo, 0);
|
|
|
|
|
|
|
|
return CommonResult.success("更新完成!");
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
log.error(ex.getMessage(), ex);
|
|
|
|
|
|
|
|
return CommonResult.failed(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String dir = "c:\\pic\\" + cardInfo.getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sync(CardInfo cardInfo) throws IOException {
|
|
|
|
|
|
|
|
String dir = "c:\\pic-makup\\" + cardInfo.getId();
|
|
|
|
// 创建File对象
|
|
|
|
// 创建File对象
|
|
|
|
File directory = new File(dir);
|
|
|
|
File directory = new File(dir);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String uniUrl = "http://192.168.8.74";
|
|
|
|
|
|
|
|
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
|
|
|
|
|
|
|
|
if (pictures == null || pictures.size() == 0) {
|
|
|
|
|
|
|
|
//如果是空的则不同步
|
|
|
|
|
|
|
|
dataQuery.updateBatchState(cardInfo, 5);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断目录是否存在
|
|
|
|
|
|
|
|
if (!directory.exists()) {
|
|
|
|
// 判断目录是否存在
|
|
|
|
// 目录不存在,创建目录
|
|
|
|
if (!directory.exists()) {
|
|
|
|
boolean created = directory.mkdirs();
|
|
|
|
// 目录不存在,创建目录
|
|
|
|
if (created) {
|
|
|
|
boolean created = directory.mkdirs();
|
|
|
|
log.info("目录创建成功:" + dir);
|
|
|
|
if (created) {
|
|
|
|
} else {
|
|
|
|
log.info("目录创建成功:" + dir);
|
|
|
|
log.info("目录创建失败:" + dir);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("目录创建失败:" + dir);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Future> futures = new ArrayList<>();
|
|
|
|
List<Future> futures = new ArrayList<>();
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
Future future = executor.submit(() -> {
|
|
|
|
Future future = executor.submit(() -> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String cmd = "C:\\Debug\\lianzhong.exe 003 192.168.8.74 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + cardInfo.getOutdateStr() + " " + picture.getPicname() + " " + picture.getMakeUpFileUrl() + " " + uniUrl + " " + picture.getRotatedegree();
|
|
|
|
String cmd = "C:\\Debug\\lianzhong.exe 003 192.168.8.74 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + cardInfo.getOutdateStr() + " " + picture.getPicname() + " " + picture.getFileUrl() + " " + uniUrl + " " + picture.getRotatedegree();
|
|
|
|
|
|
|
|
// log.info(cmd);
|
|
|
|
// log.info(cmd);
|
|
|
|
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
|
|
|
|
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
|
|
|
|
process.waitFor();
|
|
|
|
process.waitFor();
|
|
|
|
} catch (Exception e) {
|
|
|
|
File pictureFile = new File(picture.getMakeUpFileUrl());
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
if (!pictureFile.exists()) {
|
|
|
|
e.printStackTrace();
|
|
|
|
log.error("图片转换失败,命令为:{}", cmd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
futures.add(future);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Future future : futures) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
future.get();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
boolean complete=true;
|
|
|
|
futures.add(future);
|
|
|
|
List<File> files = new ArrayList<>();
|
|
|
|
}
|
|
|
|
List<UploadInfo> uploadInfos = new ArrayList<>();
|
|
|
|
for (Future future : futures) {
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
try {
|
|
|
|
File pictureFile = new File(picture.getMakeUpFileUrl());
|
|
|
|
future.get();
|
|
|
|
if(!pictureFile.exists()){
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
complete=false;
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
continue;
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
}
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
files.add(pictureFile);
|
|
|
|
|
|
|
|
UploadInfo uploadInfo = new UploadInfo(cardInfo.getPatno(), cardInfo.getOutdateStr2(), picture.getPicname(), picture.getPicname(),
|
|
|
|
|
|
|
|
picture.getPickind(), cardInfo.getId(), cardInfo.getPatname(),
|
|
|
|
|
|
|
|
cardInfo.getIndateStr(), cardInfo.getPatsex(), cardInfo.getPatnum(),
|
|
|
|
|
|
|
|
cardInfo.getIcdecode11(), cardInfo.getIcdename11(), cardInfo.getMjwesticde(), cardInfo.getMjwestname(),
|
|
|
|
|
|
|
|
cardInfo.getOutdeptname(), cardInfo.getPatciticard(), cardInfo.getOutwardname(), cardInfo.getIndeptname(), cardInfo.getIndeptcode(), cardInfo.getGestno(), cardInfo.getPatbirthdayStr());
|
|
|
|
|
|
|
|
uploadInfos.add(uploadInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<File> files = new ArrayList<>();
|
|
|
|
if (files.isEmpty()) {
|
|
|
|
List<UploadInfo> uploadInfos = new ArrayList<>();
|
|
|
|
dataQuery.updateBatchState(cardInfo,4);
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
// 删除文件
|
|
|
|
files.add(new File(picture.getFileUrl()));
|
|
|
|
FileUploader.deleteFolder(directory);
|
|
|
|
UploadInfo uploadInfo = new UploadInfo(cardInfo.getPatno(), cardInfo.getOutdateStr2(), picture.getPicname(), picture.getPicname(),
|
|
|
|
return;
|
|
|
|
picture.getPickind(), cardInfo.getId(), cardInfo.getPatname(),
|
|
|
|
}
|
|
|
|
cardInfo.getIndateStr(), cardInfo.getPatsex(), cardInfo.getPatnum(),
|
|
|
|
|
|
|
|
cardInfo.getIcdecode11(), cardInfo.getIcdename11(), cardInfo.getMjwesticde(), cardInfo.getMjwestname(),
|
|
|
|
|
|
|
|
cardInfo.getOutdeptname(), cardInfo.getPatciticard(), cardInfo.getOutwardname(), cardInfo.getIndeptname(), cardInfo.getIndeptcode(), cardInfo.getGestno(), cardInfo.getPatbirthdayStr());
|
|
|
|
|
|
|
|
uploadInfos.add(uploadInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 额外的表单字段参数
|
|
|
|
// 额外的表单字段参数
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
List<FormField> params = new ArrayList<>();
|
|
|
|
String s = new Gson().toJson(uploadInfos);
|
|
|
|
String s = new Gson().toJson(uploadInfos);
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
params.add(new FormField("uploadFileParams", s));
|
|
|
|
log.info("请求参数:" + cardInfo.getPatno());
|
|
|
|
log.info("请求参数:" + cardInfo.getPatno());
|
|
|
|
|
|
|
|
|
|
|
|
// 上传
|
|
|
|
// 上传
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
|
|
|
|
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
|
|
|
|
if (commonResult.getCode() == 0) {
|
|
|
|
if (commonResult.getCode() == 0) {
|
|
|
|
dataQuery.updateBatchState(cardInfo, 3);
|
|
|
|
dataQuery.updateBatchState(cardInfo, 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!complete) {
|
|
|
|
|
|
|
|
// 不完整
|
|
|
|
|
|
|
|
dataQuery.updateBatchState(cardInfo,2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 删除文件
|
|
|
|
|
|
|
|
FileUploader.deleteFolder(directory);
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
if (directory.exists()) {
|
|
|
|
|
|
|
|
FileUploader.deleteFolder(directory);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除文件
|
|
|
|
|
|
|
|
File file = new File(dir);
|
|
|
|
|
|
|
|
FileUploader.deleteFolder(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|