| | |
| | | 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; |
| | |
| | | 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)); |
| | |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | throw new ServiceException("500", "填写数据类型错误:第" + index + "行" + e.getMessage()); |
| | | throw new ServiceException("500", "填写数据格式错误:第" + index + "行" + e.getMessage()); |
| | | } |
| | | } |
| | | } |