Commit b7150e10 by 刘栋

UDI-校验逻辑增加

parent b3c5e98a
...@@ -82,23 +82,14 @@ public class TaskImportServiceImpl implements TaskImportService { ...@@ -82,23 +82,14 @@ public class TaskImportServiceImpl implements TaskImportService {
boolean errorFlag = false; boolean errorFlag = false;
for (TaskUdiExcelImportVo importVo : excelList) { for (TaskUdiExcelImportVo importVo : excelList) {
StringBuilder errorBuilder = new StringBuilder(); StringBuilder errorBuilder = new StringBuilder();
// 校验逻辑 - 是否还有较深的校验逻辑 todo
if(StringUtils.isBlank(importVo.getUdiCode()) // 校验逻辑
&& StringUtils.isBlank(importVo.getYiBaoCode()) this.valid(importVo,errorBuilder);
&& StringUtils.isBlank(importVo.getCompanyName())
&& StringUtils.isBlank(importVo.getProductFactoryCode())
&& StringUtils.isBlank(importVo.getBrandName())
&& StringUtils.isBlank(importVo.getProductName())
&& StringUtils.isBlank(importVo.getSpecification())
&& StringUtils.isBlank(importVo.getModel())
){
errorFlag = true;
errorBuilder.append("必填字段不能都为空");
}
TaskUdiExcelExportVo taskUdiExcelExportVo = new TaskUdiExcelExportVo(); TaskUdiExcelExportVo taskUdiExcelExportVo = new TaskUdiExcelExportVo();
BeanUtils.copyProperties(importVo,taskUdiExcelExportVo); BeanUtils.copyProperties(importVo,taskUdiExcelExportVo);
if(StringUtils.isNotBlank(errorBuilder.toString())){ if(StringUtils.isNotBlank(errorBuilder.toString())){
errorFlag = true;
taskUdiExcelExportVo.setResult(errorBuilder.toString()); taskUdiExcelExportVo.setResult(errorBuilder.toString());
}else{ }else{
taskUdiExcelExportVo.setResult("成功"); taskUdiExcelExportVo.setResult("成功");
...@@ -112,7 +103,12 @@ public class TaskImportServiceImpl implements TaskImportService { ...@@ -112,7 +103,12 @@ public class TaskImportServiceImpl implements TaskImportService {
UploadResultVo resultUpload = upload(resultList, TaskUdiExcelExportVo.class); UploadResultVo resultUpload = upload(resultList, TaskUdiExcelExportVo.class);
if(!errorFlag){ // 处理返回
ImportItemCount count = new ImportItemCount();
if(errorFlag){
count.addFailNum(excelList.size());
}else{
stopWatch.stop(); stopWatch.stop();
stopWatch.start("保存任务"); stopWatch.start("保存任务");
// 判断成功后,将源文件上传,得到源文件保存地址 // 判断成功后,将源文件上传,得到源文件保存地址
...@@ -123,10 +119,9 @@ public class TaskImportServiceImpl implements TaskImportService { ...@@ -123,10 +119,9 @@ public class TaskImportServiceImpl implements TaskImportService {
Integer taskFileCount = excelList.size(); Integer taskFileCount = excelList.size();
// 保存到task中 // 保存到task中
taskHelper.saveTask(taskFileSize, taskFileCount, taskFileAddress, taskFileId); taskHelper.saveTask(taskFileSize, taskFileCount, taskFileAddress, taskFileId);
count.addSuccessNum(excelList.size());
} }
// 处理返回
ImportItemCount count = new ImportItemCount();
count.addTotalNum(excelList.size()); count.addTotalNum(excelList.size());
stopWatch.stop(); stopWatch.stop();
...@@ -178,4 +173,49 @@ public class TaskImportServiceImpl implements TaskImportService { ...@@ -178,4 +173,49 @@ public class TaskImportServiceImpl implements TaskImportService {
return upload; return upload;
} }
/**
* 校验逻辑
*/
private void valid(TaskUdiExcelImportVo importVo,StringBuilder errorBuilder){
// 校验逻辑 - 是否还有较深的校验逻辑 todo
if(StringUtils.isBlank(importVo.getUdiCode())
&& StringUtils.isBlank(importVo.getYiBaoCode())
&& StringUtils.isBlank(importVo.getCompanyName())
&& StringUtils.isBlank(importVo.getProductFactoryCode())
&& StringUtils.isBlank(importVo.getBrandName())
&& StringUtils.isBlank(importVo.getProductName())
&& StringUtils.isBlank(importVo.getSpecification())
&& StringUtils.isBlank(importVo.getModel())
){
errorBuilder.append("必填字段不能都为空");
}
String udiCode = importVo.getUdiCode();
if(StringUtils.isNotBlank(udiCode)){
if(!udiPrefixValid(udiCode)){
errorBuilder.append("udi数据格式不正确(69开头或者MA开头);");
}
}
String yiBaoCode = importVo.getYiBaoCode();
if(StringUtils.isNotBlank(yiBaoCode)){
if(!yiBaoCodePrefixValid(yiBaoCode)){
errorBuilder.append("医保编码数据格式不正确(C开头);");
}
}
}
/**
* udi字符串开头匹配
*/
private boolean udiPrefixValid(String input) {
return input.startsWith("69") || input.startsWith("MA");
}
/**
* 医保编码字符串开头匹配
*/
private boolean yiBaoCodePrefixValid(String input) {
return input.startsWith("C");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment