|
|
|
@ -1,19 +1,34 @@
|
|
|
|
|
package com.air.facilities.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.json.JSON; |
|
|
|
|
import com.air.baseRegion.dto.BaseRegionDTO; |
|
|
|
|
import com.air.baseRegion.entity.BaseRegion; |
|
|
|
|
import com.air.baseRegion.mapper.BaseRegionMapper; |
|
|
|
|
import com.air.baseRegion.vo.BaseRegionVO; |
|
|
|
|
import com.air.facilities.dto.FacilitiesDTO; |
|
|
|
|
import com.air.facilities.dto.FacilitiesFileDTO; |
|
|
|
|
import com.air.facilities.entity.Facilities; |
|
|
|
|
import com.air.facilities.mapper.FacilitiesMapper; |
|
|
|
|
import com.air.facilities.service.FacilitiesService; |
|
|
|
|
import com.air.land.entity.LandListed; |
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.excel.read.listener.PageReadListener; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.cinderella.framework.common.core.exception.BusinessException; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -22,14 +37,19 @@ import java.util.List;
|
|
|
|
|
* @author: cyz |
|
|
|
|
* @create: 2022-07-07 15:44 |
|
|
|
|
**/ |
|
|
|
|
@Slf4j |
|
|
|
|
@Service |
|
|
|
|
public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilities> implements FacilitiesService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private FacilitiesMapper facilitiesMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private BaseRegionMapper baseRegionMapper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询全部数据 |
|
|
|
|
* |
|
|
|
|
* @param facilities |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -41,6 +61,7 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据ID查询具体信息 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -52,13 +73,14 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改周边信息 |
|
|
|
|
* |
|
|
|
|
* @param facilities |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public int putFacilities(Facilities facilities) { |
|
|
|
|
|
|
|
|
|
return facilitiesMapper.update(facilities,null); |
|
|
|
|
return facilitiesMapper.update(facilities, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -73,19 +95,21 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加 |
|
|
|
|
* |
|
|
|
|
* @param facilitiesDTO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public int addFacilities(FacilitiesDTO facilitiesDTO) { |
|
|
|
|
Facilities facilities = new Facilities(); |
|
|
|
|
BeanUtils.copyProperties(facilitiesDTO,facilities); |
|
|
|
|
String srt = "POINT("+facilitiesDTO.getLon()+" "+facilitiesDTO.getLat()+")"; |
|
|
|
|
BeanUtils.copyProperties(facilitiesDTO, facilities); |
|
|
|
|
String srt = "POINT(" + facilitiesDTO.getLon() + " " + facilitiesDTO.getLat() + ")"; |
|
|
|
|
facilities.setGeom(srt); |
|
|
|
|
if(StrUtil.isNotBlank(facilitiesDTO.getOldType())){ |
|
|
|
|
if (StrUtil.isNotBlank(facilitiesDTO.getOldType())) { |
|
|
|
|
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda(). |
|
|
|
|
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType())); |
|
|
|
|
if(facilities1.size() > 0){ |
|
|
|
|
if (facilities1.size() > 0) { |
|
|
|
|
facilities.setType(facilities1.get(0).getType()); |
|
|
|
|
facilities.setTypecn(facilities1.get(0).getTypecn()); |
|
|
|
|
} |
|
|
|
@ -96,30 +120,33 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询周边类型集合 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<Facilities> selectTypeList() { |
|
|
|
|
|
|
|
|
|
return facilitiesMapper.selectTypeList(); |
|
|
|
|
return facilitiesMapper.selectTypeList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改 |
|
|
|
|
* |
|
|
|
|
* @param facilitiesDTO |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public int updateFacilities(FacilitiesDTO facilitiesDTO) { |
|
|
|
|
Facilities facilities = new Facilities(); |
|
|
|
|
BeanUtils.copyProperties(facilitiesDTO,facilities); |
|
|
|
|
String srt = "POINT("+facilitiesDTO.getLon()+" "+facilitiesDTO.getLat()+")"; |
|
|
|
|
BeanUtils.copyProperties(facilitiesDTO, facilities); |
|
|
|
|
String srt = "POINT(" + facilitiesDTO.getLon() + " " + facilitiesDTO.getLat() + ")"; |
|
|
|
|
facilities.setGeom(srt); |
|
|
|
|
facilities.setGid(facilitiesDTO.getGid()); |
|
|
|
|
if(StrUtil.isNotBlank(facilitiesDTO.getOldType())){ |
|
|
|
|
if (StrUtil.isNotBlank(facilitiesDTO.getOldType())) { |
|
|
|
|
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda(). |
|
|
|
|
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType())); |
|
|
|
|
if(facilities1.size() > 0){ |
|
|
|
|
if (facilities1.size() > 0) { |
|
|
|
|
facilities.setType(facilities1.get(0).getType()); |
|
|
|
|
facilities.setTypecn(facilities1.get(0).getTypecn()); |
|
|
|
|
} |
|
|
|
@ -127,4 +154,60 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
} |
|
|
|
|
return facilitiesMapper.updateFacilities(facilities); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导入周边信息 |
|
|
|
|
* |
|
|
|
|
* @param file |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean importFile(MultipartFile file) { |
|
|
|
|
try { |
|
|
|
|
InputStream inputStream = file.getInputStream(); |
|
|
|
|
EasyExcel.read(inputStream, FacilitiesFileDTO.class, new PageReadListener<FacilitiesFileDTO>(dataList -> { |
|
|
|
|
dataList.forEach( demoData -> { |
|
|
|
|
// for (FacilitiesFileDTO demoData : dataList) {
|
|
|
|
|
Facilities facilities = new Facilities(); |
|
|
|
|
facilities.setName(demoData.getName()); |
|
|
|
|
String[] split = demoData.getNautica().split(","); |
|
|
|
|
String srt = "POINT(" + split[0] + " " + split[1] + ")"; |
|
|
|
|
String s = split[0]; |
|
|
|
|
BigDecimal bd=new BigDecimal(s); |
|
|
|
|
facilities.setLon(bd);//经度
|
|
|
|
|
String se = split[1]; |
|
|
|
|
BigDecimal bed=new BigDecimal(se); |
|
|
|
|
facilities.setLat(bed);//纬度
|
|
|
|
|
facilities.setGeom(srt); |
|
|
|
|
//查询周边类型
|
|
|
|
|
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda() |
|
|
|
|
.eq(StringUtils.isNotBlank(demoData.getClassify()), Facilities::getTypecn, demoData.getClassify())); |
|
|
|
|
if(facilities1.size() > 0 ){ |
|
|
|
|
facilities.setType(facilities1.get(0).getType()); |
|
|
|
|
facilities.setTypecn(facilities1.get(0).getTypecn()); |
|
|
|
|
}else{ |
|
|
|
|
throw new BusinessException("没有该分类"); |
|
|
|
|
} |
|
|
|
|
//查询地区ID
|
|
|
|
|
BaseRegionDTO baseRegionDTO = new BaseRegionDTO(); |
|
|
|
|
baseRegionDTO.setProvince(demoData.getProvince()); |
|
|
|
|
baseRegionDTO.setCity(demoData.getCity()); |
|
|
|
|
baseRegionDTO.setArea(demoData.getArea()); |
|
|
|
|
BaseRegionVO baseRegionVO = baseRegionMapper.selectBaseRegion(baseRegionDTO); |
|
|
|
|
facilities.setSite(baseRegionVO.getXianId()); |
|
|
|
|
if(StringUtils.isNotBlank(demoData.getAddress())){ |
|
|
|
|
facilities.setAddress(demoData.getAddress()); |
|
|
|
|
} |
|
|
|
|
facilitiesMapper.insertFacilities(facilities); |
|
|
|
|
}); |
|
|
|
|
})).sheet().headRowNumber(1).doRead(); |
|
|
|
|
return true; |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|