Commit 369779a7 authored by wangqiang's avatar wangqiang

功能开发:ICM导入前数据校验

parent 01b18cac
...@@ -71,6 +71,22 @@ public class ExtICMExternalInterfacePlanController<V extends ExtICMExternalInter ...@@ -71,6 +71,22 @@ public class ExtICMExternalInterfacePlanController<V extends ExtICMExternalInter
return ApiResult.ok(extICMExternalInterfacePlanService.autoImportICMPlan(id),"ICM计划自动导入成功"); return ApiResult.ok(extICMExternalInterfacePlanService.autoImportICMPlan(id),"ICM计划自动导入成功");
} }
/**
* 导入ICM计划校验
*
* @param fileId
* @param projectId
* @return
* @throws IOException
*/
@ApiOperation("校验上传的excel中的ICM计划列表是否合法")
@PostMapping(value = "/verifyExcelDataIsValid")
public ApiResult verifyExcelDataIsValid(@RequestParam(value = "fileId",required = true)Long fileId,
@RequestParam(value ="projectId",required = true) String projectId)
throws IOException {
return ApiResult.ok(extICMExternalInterfacePlanService.verifyExcelDataIsValid(fileId,projectId),"校验成功!");
}
} }
...@@ -51,7 +51,7 @@ public class ICMPlanExcelListenner extends AnalysisEventListener<ExtICMPlanExcel ...@@ -51,7 +51,7 @@ public class ICMPlanExcelListenner extends AnalysisEventListener<ExtICMPlanExcel
/** /**
* excel数据行数 * excel数据行数
*/ */
private Integer excelDataRow = 0; private Integer excelDataRow = 2;
/** /**
...@@ -78,9 +78,10 @@ public class ICMPlanExcelListenner extends AnalysisEventListener<ExtICMPlanExcel ...@@ -78,9 +78,10 @@ public class ICMPlanExcelListenner extends AnalysisEventListener<ExtICMPlanExcel
@Override @Override
public void invoke(ExtICMPlanExcelVO extICMPlanExcelVO, AnalysisContext analysisContext) { public void invoke(ExtICMPlanExcelVO extICMPlanExcelVO, AnalysisContext analysisContext) {
excelDataRow++;
//判断是否是空数据行 //判断是否是空数据行
if(!CommonUtils.checkAllPropertiesIsEmpty(extICMPlanExcelVO)){ if(!CommonUtils.checkAllPropertiesIsEmpty(extICMPlanExcelVO)){
excelDataRow++;
log.info("解析到一条数据:{}", extICMPlanExcelVO); log.info("解析到一条数据:{}", extICMPlanExcelVO);
//检查excel数据合法性 //检查excel数据合法性
checkDataForExcel(extICMPlanExcelVO); checkDataForExcel(extICMPlanExcelVO);
......
...@@ -22,4 +22,6 @@ public interface ExtICMExternalInterfacePlanService<V extends ExtICMExternalInte ...@@ -22,4 +22,6 @@ public interface ExtICMExternalInterfacePlanService<V extends ExtICMExternalInte
String exportICMPlan(HttpServletResponse response, List<String> ids) throws IOException; String exportICMPlan(HttpServletResponse response, List<String> ids) throws IOException;
String autoImportICMPlan(long id); String autoImportICMPlan(long id);
public String verifyExcelDataIsValid(Long fileId,String projectId);
} }
...@@ -9,7 +9,10 @@ import com.yonde.dcs.document.common.entity.vo.DxDocumentVO; ...@@ -9,7 +9,10 @@ import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.constants.Constants; import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.vo.ExtICMExternalInterfacePlanVO; import com.yonde.dcs.plan.common.vo.ExtICMExternalInterfacePlanVO;
import com.yonde.dcs.plan.common.vo.ExtICMPlanExcelVO; import com.yonde.dcs.plan.common.vo.ExtICMPlanExcelVO;
import com.yonde.dcs.plan.common.vo.ExtPuchasePlanExcelVO;
import com.yonde.dcs.plan.core.listener.ICMPlanExcelDataVerifyListenner;
import com.yonde.dcs.plan.core.listener.ICMPlanExcelListenner; import com.yonde.dcs.plan.core.listener.ICMPlanExcelListenner;
import com.yonde.dcs.plan.core.listener.PurchasePlanExcelDataVerifyListenner;
import com.yonde.dcs.plan.core.repository.ExtICMExternalInterfacePlanRepository; import com.yonde.dcs.plan.core.repository.ExtICMExternalInterfacePlanRepository;
import com.yonde.dcs.plan.core.service.ExtICMExternalInterfacePlanService; import com.yonde.dcs.plan.core.service.ExtICMExternalInterfacePlanService;
import com.yonde.dcs.plan.core.util.FileUtils; import com.yonde.dcs.plan.core.util.FileUtils;
...@@ -29,6 +32,7 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -29,6 +32,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -164,6 +168,25 @@ public class ExtICMExternalInterfacePlanServiceImpl<V extends ExtICMExternalInte ...@@ -164,6 +168,25 @@ public class ExtICMExternalInterfacePlanServiceImpl<V extends ExtICMExternalInte
return ApiResult.SUCCESS; return ApiResult.SUCCESS;
} }
@Override
public String verifyExcelDataIsValid(Long fileId, String projectId) {
MultipartFile multipartFile = null;
InputStream inputStream = null;
try {
multipartFile = fileManagerFeignService.feignDownloadIO(fileId);
inputStream = new ByteArrayInputStream(multipartFile.getBytes());
} catch (IOException e) {
throw new DxBusinessException("-1","文件id:"+fileId+"在系统中未找到!");
}
EasyExcel.read(inputStream, ExtPuchasePlanExcelVO.class,
new ICMPlanExcelDataVerifyListenner(projectId))
.sheet()
.doRead();
return ApiResult.SUCCESS;
}
} }
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 to comment