Commit b7150e10 by 刘栋

UDI-校验逻辑增加

parent b3c5e98a
......@@ -82,23 +82,14 @@ public class TaskImportServiceImpl implements TaskImportService {
boolean errorFlag = false;
for (TaskUdiExcelImportVo importVo : excelList) {
StringBuilder errorBuilder = new StringBuilder();
// 校验逻辑 - 是否还有较深的校验逻辑 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())
){
errorFlag = true;
errorBuilder.append("必填字段不能都为空");
}
// 校验逻辑
this.valid(importVo,errorBuilder);
TaskUdiExcelExportVo taskUdiExcelExportVo = new TaskUdiExcelExportVo();
BeanUtils.copyProperties(importVo,taskUdiExcelExportVo);
if(StringUtils.isNotBlank(errorBuilder.toString())){
errorFlag = true;
taskUdiExcelExportVo.setResult(errorBuilder.toString());
}else{
taskUdiExcelExportVo.setResult("成功");
......@@ -112,7 +103,12 @@ public class TaskImportServiceImpl implements TaskImportService {
UploadResultVo resultUpload = upload(resultList, TaskUdiExcelExportVo.class);
if(!errorFlag){
// 处理返回
ImportItemCount count = new ImportItemCount();
if(errorFlag){
count.addFailNum(excelList.size());
}else{
stopWatch.stop();
stopWatch.start("保存任务");
// 判断成功后,将源文件上传,得到源文件保存地址
......@@ -123,10 +119,9 @@ public class TaskImportServiceImpl implements TaskImportService {
Integer taskFileCount = excelList.size();
// 保存到task中
taskHelper.saveTask(taskFileSize, taskFileCount, taskFileAddress, taskFileId);
count.addSuccessNum(excelList.size());
}
// 处理返回
ImportItemCount count = new ImportItemCount();
count.addTotalNum(excelList.size());
stopWatch.stop();
......@@ -178,4 +173,49 @@ public class TaskImportServiceImpl implements TaskImportService {
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