feat: 市一联众添加检查接口

广州市市一联众
wyb 8 months ago
parent 46499927e1
commit 470192354a

@ -8,11 +8,15 @@ import com.jiashi.service.CardInfo;
import com.jiashi.service.FormField; import com.jiashi.service.FormField;
import com.jiashi.service.Picture; import com.jiashi.service.Picture;
import com.jiashi.service.UploadInfo; import com.jiashi.service.UploadInfo;
import com.sun.xml.internal.ws.util.CompletedFuture;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -24,10 +28,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ExecutionException; import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/** /**
* @author YongBin Wen * @author YongBin Wen
@ -69,6 +70,100 @@ public class LianZhongSyncController {
} }
} }
@ApiOperation(value = "联众图片数据同步检查")
@GetMapping("/sync/checkReport")
public CommonResult<String> syncCheckReport() {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<CardInfo> cardInfos = dataQuery.dateQuery(2);
if (CollectionUtils.isEmpty(cardInfos)) {
return CommonResult.success("没有可检查的患者,状态=2");
}
StringBuilder stringBuilder = new StringBuilder();
List<Future<String>> futures=new ArrayList<>();
for (CardInfo cardInfo : cardInfos) {
Future<String> future = executor.submit(() -> check(cardInfo));
futures.add(future);
}
for (Future<String> future : futures) {
String result = future.get();
if (!ObjectUtils.isEmpty(result)) {
stringBuilder.append(result).append(";\n");
}
}
return CommonResult.success(stringBuilder.toString());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return CommonResult.failed(ex.getMessage());
}
}
private String check(CardInfo cardInfo) throws IOException {
String dir = "c:\\pic-check\\" + cardInfo.getId();
// 创建File对象
File directory = new File(dir);
try {
String uniUrl = "http://192.168.8.74";
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
// 判断目录是否存在
if (!directory.exists()) {
// 目录不存在,创建目录
boolean created = directory.mkdirs();
if (created) {
log.info("目录创建成功:" + dir);
} else {
log.info("目录创建失败:" + dir);
}
}
List<String> faultNames = new ArrayList<>();
for (Picture picture : pictures) {
String cmd = "C:\\Debug\\lianzhong.exe 003 192.168.8.74 " + cardInfo.getId() + " " + picture.getPicid() + " " + cardInfo.getPatno() + " " + cardInfo.getOutdateStr() + " " + picture.getPicname() + " " + picture.getCheckUpFileUrl() + " " + uniUrl + " " + picture.getRotatedegree();
File pictureFile = new File(picture.getCheckUpFileUrl());
int tryNum = 0;
while (tryNum <= 3) {
tryNum++;
try {
getPic(cmd);
if (pictureFile.exists()) {
break;
}
} catch (Exception ex) {
// no
}
}
if (!pictureFile.exists()) {
faultNames.add(picture.getPicname());
}
}
if (faultNames.isEmpty()) {
return null;
}
String join = String.join(",", faultNames);
String result = "id" + cardInfo.getId() + ",住院号:" + cardInfo.getPatno() + ",出院日期:" + cardInfo.getOutdateStr() + ",文件:" + join + " 缺失";
// 删除文件
FileUploader.deleteFolder(directory);
return result;
} catch (Exception ex) {
log.error("检查出错:" + ex.getMessage(), ex);
FileUploader.deleteFolder(directory);
return "住院号:" + cardInfo.getPatno() + " 出院日期:" + cardInfo.getOutdateStr() + " 检查失败!";
}
}
private void getPic(String cmd) throws Exception {
java.lang.Process process = java.lang.Runtime.getRuntime().exec(cmd);//执行命令生成cube
process.waitFor();
}
@ApiOperation(value = "根据病案号和出院日期(yyyy-MM-dd)更新联众文件数据状态为0 ,需要重新同步 ") @ApiOperation(value = "根据病案号和出院日期(yyyy-MM-dd)更新联众文件数据状态为0 ,需要重新同步 ")
@GetMapping("/updateState/byInpNoAndDisDate") @GetMapping("/updateState/byInpNoAndDisDate")
public CommonResult<String> updateStateByInpNoAndDisDate(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("disDate") String disDate) { public CommonResult<String> updateStateByInpNoAndDisDate(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("disDate") String disDate) {
@ -147,13 +242,13 @@ public class LianZhongSyncController {
} }
} }
boolean complete=true; boolean complete = true;
List<File> files = new ArrayList<>(); List<File> files = new ArrayList<>();
List<UploadInfo> uploadInfos = new ArrayList<>(); List<UploadInfo> uploadInfos = new ArrayList<>();
for (Picture picture : pictures) { for (Picture picture : pictures) {
File pictureFile = new File(picture.getMakeUpFileUrl()); File pictureFile = new File(picture.getMakeUpFileUrl());
if(!pictureFile.exists()){ if (!pictureFile.exists()) {
complete=false; complete = false;
continue; continue;
} }
files.add(pictureFile); files.add(pictureFile);
@ -166,7 +261,7 @@ public class LianZhongSyncController {
} }
if (files.isEmpty()) { if (files.isEmpty()) {
dataQuery.updateBatchState(cardInfo,4); dataQuery.updateBatchState(cardInfo, 4);
// 删除文件 // 删除文件
FileUploader.deleteFolder(directory); FileUploader.deleteFolder(directory);
return; return;
@ -187,7 +282,7 @@ public class LianZhongSyncController {
} }
if (!complete) { if (!complete) {
// 不完整 // 不完整
dataQuery.updateBatchState(cardInfo,2); dataQuery.updateBatchState(cardInfo, 2);
} }
// 删除文件 // 删除文件
FileUploader.deleteFolder(directory); FileUploader.deleteFolder(directory);

@ -39,6 +39,17 @@ public class DataQuery {
return all.toList(); return all.toList();
} }
public List<CardInfo> dateQuery(int state){
Specification<CardInfo> specification = (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.<String>get("state"), state));
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
};
List<CardInfo> all = cardInfoRepository.findAll(specification);
return all;
}
public List<CardInfo> dateQueryByInpNo(String inpNo){ public List<CardInfo> dateQueryByInpNo(String inpNo){
Specification<CardInfo> specification = (root, query, cb) -> { Specification<CardInfo> specification = (root, query, cb) -> {

@ -38,4 +38,8 @@ public class Picture {
return fileUrl; return fileUrl;
} }
public String getCheckUpFileUrl(){
String fileUrl = "c:/pic-check/" + this.getFileid() + "/" + this.getPicname();
return fileUrl;
}
} }

Loading…
Cancel
Save