feat: 市一联众添加接口修改状态

广州市市一联众
wyb 10 months ago
parent 03eb85f2f9
commit 46499927e1

@ -69,83 +69,134 @@ public class LianZhongSyncController {
}
}
public void sync(CardInfo cardInfo) throws IOException {
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;
@ApiOperation(value = "根据病案号和出院日期(yyyy-MM-dd)更新联众文件数据状态为0 ,需要重新同步 ")
@GetMapping("/updateState/byInpNoAndDisDate")
public CommonResult<String> updateStateByInpNoAndDisDate(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("disDate") String disDate) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<CardInfo> cardInfos = dataQuery.dateQueryByInpNo(inpatientNo);
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 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()) {
// 目录不存在,创建目录
boolean created = directory.mkdirs();
if (created) {
log.info("目录创建成功:" + dir);
} else {
log.info("目录创建失败:" + dir);
// 判断目录是否存在
if (!directory.exists()) {
// 目录不存在,创建目录
boolean created = directory.mkdirs();
if (created) {
log.info("目录创建成功:" + dir);
} else {
log.info("目录创建失败:" + dir);
}
}
}
List<Future> futures = new ArrayList<>();
for (Picture picture : pictures) {
Future future = executor.submit(() -> {
try {
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();
List<Future> futures = new ArrayList<>();
for (Picture picture : pictures) {
Future future = executor.submit(() -> {
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();
// log.info(cmd);
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
File pictureFile = new File(picture.getMakeUpFileUrl());
if (!pictureFile.exists()) {
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);
}
}
});
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;
List<File> files = new ArrayList<>();
List<UploadInfo> uploadInfos = new ArrayList<>();
for (Picture picture : pictures) {
File pictureFile = new File(picture.getMakeUpFileUrl());
if(!pictureFile.exists()){
complete=false;
continue;
}
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<>();
List<UploadInfo> uploadInfos = new ArrayList<>();
for (Picture picture : pictures) {
files.add(new File(picture.getFileUrl()));
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);
}
if (files.isEmpty()) {
dataQuery.updateBatchState(cardInfo,4);
// 删除文件
FileUploader.deleteFolder(directory);
return;
}
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfos);
params.add(new FormField("uploadFileParams", s));
log.info("请求参数:" + cardInfo.getPatno());
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
String s = new Gson().toJson(uploadInfos);
params.add(new FormField("uploadFileParams", s));
log.info("请求参数:" + cardInfo.getPatno());
// 上传
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
if (commonResult.getCode() == 0) {
dataQuery.updateBatchState(cardInfo, 3);
// 上传
CommonResult commonResult = FileUploader.uploadFilesWithParams(files, "http://192.168.161.102:9511/fileUploadJpg", params);
if (commonResult.getCode() == 0) {
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);
}

@ -33,4 +33,9 @@ public class Picture {
return fileUrl;
}
public String getMakeUpFileUrl(){
String fileUrl = "c:/pic-makup/" + this.getFileid() + "/" + this.getPicname();
return fileUrl;
}
}

@ -46,6 +46,9 @@ public class UpdateService {
for (CardInfo cardInfo : cardInfos) {
log.info("开始同步"+cardInfo.getPatno());
Future future2 = executor2.submit(()->{
String dir = "c:\\pic\\"+cardInfo.getId();
// 创建File对象
File directory = new File(dir);
try{
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
if(pictures==null||pictures.size()==0){
@ -53,9 +56,6 @@ public class UpdateService {
dataQuery.updateBatchState(cardInfo,5);
return;
}
String dir = "c:\\pic\\"+cardInfo.getId();
// 创建File对象
File directory = new File(dir);
// 判断目录是否存在
if (!directory.exists()) {
@ -75,6 +75,10 @@ public class UpdateService {
// log.info(cmd);
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
File pictureFile = new File(picture.getFileUrl());
if(!pictureFile.exists()){
log.error("图片转换失败,命令为:{}",cmd);
}
} catch (Exception e) {
log.error(e.getMessage(),e);
e.printStackTrace();
@ -93,10 +97,16 @@ public class UpdateService {
}
}
boolean complete = true;
List<File> files = new ArrayList<>();
List<UploadInfo> uploadInfos = new ArrayList<>();
for(Picture picture : pictures){
files.add(new File(picture.getFileUrl()));
File pictureFile = new File(picture.getFileUrl());
if(!pictureFile.exists()){
complete=false;
continue;
}
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(),
@ -105,6 +115,13 @@ public class UpdateService {
uploadInfos.add(uploadInfo);
}
if (files.isEmpty()) {
log.info("获取图片文件失败,cardInfoId:{}",cardInfo.getId());
dataQuery.updateBatchState(cardInfo,4);
// 删除文件
FileUploader.deleteFolder(directory);
return;
}
// 额外的表单字段参数
List<FormField> params = new ArrayList<>();
@ -125,13 +142,19 @@ public class UpdateService {
dataQuery.updateBatchState(cardInfo,4);
log.error(e.getMessage(),e);
}
if (!complete) {
// 不完整
dataQuery.updateBatchState(cardInfo,2);
}
// 删除文件
File file = new File(dir);
FileUploader.deleteFolder(file);
FileUploader.deleteFolder(directory);
}catch (Exception e){
dataQuery.updateBatchState(cardInfo,4);
log.error(e.getMessage(),e);
e.printStackTrace();
if (directory.exists()) {
FileUploader.deleteFolder(directory);
}
}
});
futures2.add(future2);

Loading…
Cancel
Save