| | |
| | | import com.panzhihua.common.model.vos.community.ComMngBuildingExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationImportErrorVO; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActVillageDAO; |
| | | import com.panzhihua.service_community.dao.ComMngBuildingDAO; |
| | |
| | | @Override |
| | | public R batchSaveBuilding(List<ComMngBuildingExcelVO> newVoList, Long communityId) { |
| | | ArrayList<ComMngBuildingDO> list = Lists.newArrayList(); |
| | | int index = 2; |
| | | List<GridBuildRelationDO> keyList = new ArrayList<>(); |
| | | List<ComMngPopulationImportErrorVO> errorList = new ArrayList<>(); |
| | | ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | | importErrorVO.setErrorMsg("重复楼栋"); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for(ComMngBuildingExcelVO vo:newVoList){ |
| | | ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getAlley()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId)); |
| | | if(comMngVillageDO == null){ |
| | |
| | | } |
| | | List<ComMngBuildingDO> buildingDOList = this.baseMapper.selectList(new QueryWrapper<ComMngBuildingDO>().eq("street_id",comMngVillageDO.getStreetId()).eq("act_id",communityId).eq("village_id",comMngVillageDO.getVillageId()).eq("name",vo.getName())); |
| | | if(buildingDOList.size() > 0){ |
| | | ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | | importErrorVO.setErrorMsg("重复楼栋"); |
| | | importErrorVO.setErrorPosition("第" + index + "行"); |
| | | errorList.add(importErrorVO); |
| | | sb.append("街路巷:").append(vo.getAlley()).append(",门牌号:").append(vo.getDoorNo()).append(",楼栋号:").append(vo.getName()).append(";"); |
| | | continue; |
| | | } |
| | | ComMngBuildingDO comMngBuildingDO = new ComMngBuildingDO(); |
| | |
| | | comMngBuildingDO.setVillageId(comMngVillageDO.getVillageId()); |
| | | ComActDO actDO = comActDAO.selectById(comMngVillageDO.getCommunityId()); |
| | | StringBuilder path = new StringBuilder(); |
| | | path.append(vo.getAlley()).append(">").append(actDO.getName()).append(vo.getVillageName()).append(">").append(vo.getName()); |
| | | path.append(vo.getAlley()).append(">").append(actDO.getName()).append(comMngVillageDO.getName()).append(">").append(vo.getName()); |
| | | comMngBuildingDO.setPath(path.toString()); |
| | | comMngBuildingDO.setGridId(vo.getGridId()); |
| | | list.add(comMngBuildingDO); |
| | | index ++; |
| | | GridBuildRelationDO gridBuildRelation = getGridBuildRelationDO(communityId, comMngVillageDO.getStreetId(), vo, comMngBuildingDO); |
| | | keyList.add(gridBuildRelation); |
| | | } |
| | |
| | | if(list.size()>0){ |
| | | this.saveBatch(list); |
| | | } |
| | | |
| | | if(errorList.size() > 0){ |
| | | if(sb.length() > 0 && !StringUtils.isEmpty(sb.toString())){ |
| | | errorList.add(importErrorVO); |
| | | return R.fail(JSON.toJSONString(errorList)); |
| | | } |
| | | gridBuildRelationService.saveBatchGridBuildRelation(keyList); |