From 376e1f1c688c71a31ee321805e443af8e92c8d5e Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期三, 31 三月 2021 17:35:11 +0800 Subject: [PATCH] 优化导入导出接口,新增实有人口导出接口 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java index 0f0458c..7e874ab 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java @@ -4,6 +4,9 @@ import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; +import com.panzhihua.common.enums.PopulIsOkEnum; +import com.panzhihua.common.enums.PopulPoliticalOutlookEnum; +import com.panzhihua.common.enums.PopulSexEnum; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; @@ -80,16 +83,34 @@ for (Map<Integer, String> oneData : list) { ComMngPopulationServeExcelVO vo = new ComMngPopulationServeExcelVO(); vo.setName(oneData.get(0)); - vo.setSex(oneData.get(1)); + vo.setSex(PopulSexEnum.getCodeByName(oneData.get(1))); + if(oneData.get(2) == null){ + throw new ServiceException("500", "年龄不可为空:第" + index + "行,第3列"); + } vo.setAge(Integer.valueOf(oneData.get(2))); - vo.setIsRent(oneData.get(3)); + if(oneData.get(3) == null){ + throw new ServiceException("500", "是否租住不可为空:第" + index + "行,第4列"); + } + vo.setIsRent(PopulIsOkEnum.getCodeByName(oneData.get(3))); vo.setRoad(oneData.get(4)); + if(oneData.get(5) == null){ + throw new ServiceException("500", "门牌号不可为空:第" + index + "行,第6列"); + } vo.setDoorNo(Integer.valueOf(oneData.get(5))); vo.setFloor(oneData.get(6)); + if(oneData.get(7) == null){ + throw new ServiceException("500", "单元号不可为空:第" + index + "行,第8列"); + } vo.setUnitNo(Integer.valueOf(oneData.get(7))); + if(oneData.get(8) == null){ + throw new ServiceException("500", "户室不可为空:第" + index + "行,第9列"); + } vo.setHouseNo(Integer.valueOf(oneData.get(8))); vo.setNation(oneData.get(9)); - vo.setPoliticalOutlook(oneData.get(10)); + if(oneData.get(10) == null){ + throw new ServiceException("500", "政治面貌不可为空:第" + index + "行,第11列"); + } + vo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCodeByName(oneData.get(10))); vo.setCardNo(oneData.get(11)); vo.setPhone(oneData.get(12)); vo.setNativePlace(oneData.get(13)); @@ -107,7 +128,7 @@ throw new ServiceException(r.getMsg()); } } catch (NumberFormatException e) { - throw new ServiceException("500", "填写数据类型错误:第" + index + "行" + e.getMessage()); + throw new ServiceException("500", "填写数据格式错误:第" + index + "行" + e.getMessage()); } } } -- Gitblit v1.7.1