修改状态字段和导入

dongdingding
杜函宇 1 year ago
parent fcf24f0494
commit f7c78a8598

@ -133,10 +133,10 @@ public class JProjectController extends BaseController {
}) })
@PostMapping(value = "/importTemplateProject",consumes ="multipart/form-data") @PostMapping(value = "/importTemplateProject",consumes ="multipart/form-data")
public AjaxResult importTemplateProject(@RequestPart("file") MultipartFile file, public AjaxResult importTemplateProject(@RequestPart("file") MultipartFile file,
@RequestParam("projectClassify")String projectClassify, @RequestParam("projectClassify")String projectClassify
@RequestParam("projectYear")String projectYear) throws Exception { ) throws Exception {
ProjectValueUtil<JProject> util = new ProjectValueUtil<>(JProject.class); ProjectValueUtil<JProject> util = new ProjectValueUtil<>(JProject.class);
List<JProject> proList = util.importExcel(file.getInputStream(),projectClassify,projectYear); List<JProject> proList = util.importExcel(file.getInputStream(),projectClassify);
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
if(proList == null && proList.isEmpty()){ if(proList == null && proList.isEmpty()){
throw new ServiceException("项目导入数据不能为空"); throw new ServiceException("项目导入数据不能为空");

@ -23,4 +23,11 @@ public class JProjectExcel {
@Excel(name = "申报单位") @Excel(name = "申报单位")
@ApiModelProperty("申报单位") @ApiModelProperty("申报单位")
private String declareUnit; private String declareUnit;
/**
*
*/
@Excel(name = "年份")
@ApiModelProperty("年份")
private String projectYear;
} }

@ -234,10 +234,10 @@ public class ProjectValueUtil<T> {
* @param is * @param is
* @return * @return
*/ */
public List<T> importExcel(InputStream is,String projectClassify,String projectYear) { public List<T> importExcel(InputStream is,String projectClassify) {
List<T> list = null; List<T> list = null;
try { try {
list = importExcel(is, 0,projectClassify,projectYear); list = importExcel(is, 0,projectClassify);
} catch (Exception e) { } catch (Exception e) {
log.error("导入Excel异常{}", e.getMessage()); log.error("导入Excel异常{}", e.getMessage());
throw new UtilException(e.getMessage()); throw new UtilException(e.getMessage());
@ -254,8 +254,8 @@ public class ProjectValueUtil<T> {
* @param titleNum * @param titleNum
* @return * @return
*/ */
public List<T> importExcel(InputStream is, int titleNum,String projectClassify,String projectYear) throws Exception { public List<T> importExcel(InputStream is, int titleNum,String projectClassify) throws Exception {
return importExcel(StringUtils.EMPTY, is, titleNum,projectClassify,projectYear); return importExcel(StringUtils.EMPTY, is, titleNum,projectClassify);
} }
/** /**
@ -266,7 +266,7 @@ public class ProjectValueUtil<T> {
* @param is * @param is
* @return * @return
*/ */
public List<T> importExcel(String sheetName, InputStream is, int titleNum,String projectClassify,String projectYear) throws Exception { public List<T> importExcel(String sheetName, InputStream is, int titleNum,String projectClassify) throws Exception {
this.type = Type.IMPORT; this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is); this.wb = WorkbookFactory.create(is);
List<T> list = new ArrayList<T>(); List<T> list = new ArrayList<T>();
@ -383,7 +383,6 @@ public class ProjectValueUtil<T> {
} }
} }
ReflectUtils.invokeSetter(entity, "projectClassify", projectClassify); ReflectUtils.invokeSetter(entity, "projectClassify", projectClassify);
ReflectUtils.invokeSetter(entity, "projectYear", projectYear);
ReflectUtils.invokeSetter(entity, "status", 5); ReflectUtils.invokeSetter(entity, "status", 5);
cellMap.entrySet().removeIf(entry -> hasStr.contains(entry.getKey())); cellMap.entrySet().removeIf(entry -> hasStr.contains(entry.getKey()));
StringBuilder str = new StringBuilder(); StringBuilder str = new StringBuilder();

Loading…
Cancel
Save