| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | 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.panzhihua.service_community.model.dos.GridBuildRelationDO; |
| | | import com.panzhihua.service_community.service.ComActBuildingService; |
| | | import com.panzhihua.service_community.service.GridBuildRelationService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author xyh |
| | | * @date 2021/6/10 13:46 |
| | | */ |
| | | @Service |
| | | public class ComActBuildingServiceImpl extends ServiceImpl<ComMngBuildingDAO, ComMngBuildingDO> implements ComActBuildingService { |
| | | public class ComActBuildingServiceImpl extends ServiceImpl<ComMngBuildingDAO, ComMngBuildingDO> |
| | | implements ComActBuildingService { |
| | | |
| | | @Resource |
| | | private ComActVillageDAO comActVillageDAO; |
| | |
| | | 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){ |
| | | 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) { |
| | | 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())); |
| | | if(buildingDOList.size() > 0){ |
| | | sb.append("街路巷:").append(vo.getAlley()).append(",门牌号:").append(vo.getDoorNo()).append(",楼栋号:").append(vo.getName()).append(";"); |
| | | 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())); |
| | | if (buildingDOList.size() > 0) { |
| | | sb.append("街路巷:").append(vo.getAlley()).append(",门牌号:").append(vo.getDoorNo()).append(",楼栋号:") |
| | | .append(vo.getName()).append(";"); |
| | | continue; |
| | | } |
| | | ComMngBuildingDO comMngBuildingDO = new ComMngBuildingDO(); |
| | | BeanUtils.copyProperties(vo,comMngBuildingDO); |
| | | BeanUtils.copyProperties(vo, comMngBuildingDO); |
| | | comMngBuildingDO.setActId(comMngVillageDO.getCommunityId()); |
| | | comMngBuildingDO.setStreetId(comMngVillageDO.getStreetId()); |
| | | comMngBuildingDO.setVillageId(comMngVillageDO.getVillageId()); |
| | | 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()); |
| | | 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); |
| | | GridBuildRelationDO gridBuildRelation = getGridBuildRelationDO(communityId, comMngVillageDO.getStreetId(), vo, comMngBuildingDO); |
| | | GridBuildRelationDO gridBuildRelation = |
| | | getGridBuildRelationDO(communityId, comMngVillageDO.getStreetId(), vo, comMngBuildingDO); |
| | | keyList.add(gridBuildRelation); |
| | | } |
| | | |
| | | if(list.size()>0){ |
| | | if (list.size() > 0) { |
| | | this.saveBatch(list); |
| | | } |
| | | if(sb.length() > 0 && !StringUtils.isEmpty(sb.toString())){ |
| | | if (sb.length() > 0 && !StringUtils.isEmpty(sb.toString())) { |
| | | errorList.add(importErrorVO); |
| | | return R.fail(JSON.toJSONString(errorList)); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | public GridBuildRelationDO getGridBuildRelationDO(Long communityId, Long streetId, ComMngBuildingExcelVO vo, ComMngBuildingDO comMngBuildingDO) { |
| | | public GridBuildRelationDO getGridBuildRelationDO(Long communityId, Long streetId, ComMngBuildingExcelVO vo, |
| | | ComMngBuildingDO comMngBuildingDO) { |
| | | GridBuildRelationDO gridBuildRelation = new GridBuildRelationDO(); |
| | | gridBuildRelation.setId(Snowflake.getId()); |
| | | gridBuildRelation.setBuildId(comMngBuildingDO.getId()); |