| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | |
| | | ArrayList<ComMngBuildingDO> list = Lists.newArrayList(); |
| | | 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) { |
| | | ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | | BeanUtils.copyProperties(vo,importErrorVO); |
| | | importErrorVO.setErrorMsg("该社区不存在此街路巷"); |
| | | errorList.add(importErrorVO); |
| | | continue; |
| | | } |
| | | vo.setName(vo.getName().replace("栋", "")); |
| | | 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())); |
| | | .eq("act_id", communityId).eq("village_id", comMngVillageDO.getVillageId()).eq("name", vo.getName())); |
| | | if (buildingDOList.size() > 0) { |
| | | sb.append("街路巷:").append(vo.getAlley()).append(",门牌号:").append(vo.getDoorNo()).append(",楼栋号:") |
| | | .append(vo.getName()).append(";"); |
| | | ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | | BeanUtils.copyProperties(vo,importErrorVO); |
| | | importErrorVO.setErrorMsg("该楼栋已存在"); |
| | | errorList.add(importErrorVO); |
| | | continue; |
| | | } |
| | | ComMngBuildingDO comMngBuildingDO = new ComMngBuildingDO(); |
| | |
| | | comMngBuildingDO.setActId(comMngVillageDO.getCommunityId()); |
| | | comMngBuildingDO.setStreetId(comMngVillageDO.getStreetId()); |
| | | comMngBuildingDO.setVillageId(comMngVillageDO.getVillageId()); |
| | | // comMngBuildingDO.setElevatorTotal(vo.getElevatorTotal()); |
| | | ComActDO actDO = comActDAO.selectById(comMngVillageDO.getCommunityId()); |
| | | StringBuilder path = new StringBuilder(); |
| | | path.append(vo.getAlley()).append(">").append(actDO.getName()).append(comMngVillageDO.getName()).append(">") |
| | | .append(vo.getName()); |
| | | comMngBuildingDO.setPath(path.toString()); |
| | | comMngBuildingDO.setGridId(vo.getGridId()); |
| | | // comMngBuildingDO.setGridId(vo.getGridId()); |
| | | list.add(comMngBuildingDO); |
| | | GridBuildRelationDO gridBuildRelation = |
| | | getGridBuildRelationDO(communityId, comMngVillageDO.getStreetId(), vo, comMngBuildingDO); |
| | |
| | | |
| | | if (list.size() > 0) { |
| | | this.saveBatch(list); |
| | | if(keyList.size() > 0){ |
| | | gridBuildRelationService.saveBatchGridBuildRelation(keyList); |
| | | } |
| | | } |
| | | if (sb.length() > 0 && !StringUtils.isEmpty(sb.toString())) { |
| | | errorList.add(importErrorVO); |
| | | return R.fail(JSON.toJSONString(errorList)); |
| | | if (errorList.size() > 0) { |
| | | return R.fail(errorList); |
| | | } |
| | | gridBuildRelationService.saveBatchGridBuildRelation(keyList); |
| | | this.saveBatch(list); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | gridBuildRelation.setVillageId(comMngBuildingDO.getVillageId()); |
| | | gridBuildRelation.setGridCommunityId(communityId); |
| | | gridBuildRelation.setGridStreetId(streetId); |
| | | if (vo.getGridId() != null) { |
| | | gridBuildRelation.setGridId(Long.valueOf(vo.getGridId())); |
| | | } |
| | | // if (vo.getGridId() != null) { |
| | | // gridBuildRelation.setGridId(Long.valueOf(vo.getGridId())); |
| | | // } |
| | | gridBuildRelation.setGridName(vo.getGridName()); |
| | | gridBuildRelation.setType(1); |
| | | gridBuildRelation.setCreateAt(new Date()); |