|
|
|
@ -1,17 +1,17 @@
|
|
|
|
|
package com.air.facilities.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
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.dictitem.entity.DictItem; |
|
|
|
|
import com.air.dictitem.mapper.DictItemMapper; |
|
|
|
|
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; |
|
|
|
@ -47,6 +47,9 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
@Autowired |
|
|
|
|
private BaseRegionMapper baseRegionMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private DictItemMapper dictItemMapper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询全部数据 |
|
|
|
|
* |
|
|
|
@ -107,15 +110,20 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
String srt = "POINT(" + facilitiesDTO.getLon() + " " + facilitiesDTO.getLat() + ")"; |
|
|
|
|
facilities.setGeom(srt); |
|
|
|
|
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) { |
|
|
|
|
facilities.setType(facilities1.get(0).getType()); |
|
|
|
|
facilities.setTypecn(facilities1.get(0).getTypecn()); |
|
|
|
|
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda() |
|
|
|
|
.eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), DictItem::getValue, facilitiesDTO.getOldType()) |
|
|
|
|
.eq(DictItem::getType, "rim") |
|
|
|
|
); |
|
|
|
|
if (ObjectUtil.isNotNull(rim)) { |
|
|
|
|
facilities.setType(rim.getValue()); |
|
|
|
|
facilities.setTypecn(rim.getLabel()); |
|
|
|
|
return facilitiesMapper.insertFacilities(facilities); |
|
|
|
|
}else{ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return facilitiesMapper.insertFacilities(facilities); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -144,15 +152,21 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
facilities.setGeom(srt); |
|
|
|
|
facilities.setGid(facilitiesDTO.getGid()); |
|
|
|
|
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) { |
|
|
|
|
facilities.setType(facilities1.get(0).getType()); |
|
|
|
|
facilities.setTypecn(facilities1.get(0).getTypecn()); |
|
|
|
|
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda() |
|
|
|
|
.eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), DictItem::getValue, facilitiesDTO.getOldType()) |
|
|
|
|
.eq(DictItem::getType, "rim") |
|
|
|
|
); |
|
|
|
|
if (ObjectUtil.isNotNull(rim)) { |
|
|
|
|
facilities.setType(rim.getValue()); |
|
|
|
|
facilities.setTypecn(rim.getLabel()); |
|
|
|
|
return facilitiesMapper.updateFacilities(facilities); |
|
|
|
|
}else{ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return facilitiesMapper.updateFacilities(facilities); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -163,11 +177,18 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public boolean importFile(MultipartFile file) { |
|
|
|
|
public int importFile(MultipartFile file) { |
|
|
|
|
try { |
|
|
|
|
//判断文件类型是否正确
|
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
|
String fileType = originalFilename.substring(originalFilename.lastIndexOf(".")); |
|
|
|
|
if (!".xls".equalsIgnoreCase(fileType) && !".xlsx".equalsIgnoreCase(fileType)) { |
|
|
|
|
return 10; |
|
|
|
|
} |
|
|
|
|
InputStream inputStream = file.getInputStream(); |
|
|
|
|
EasyExcel.read(inputStream, FacilitiesFileDTO.class, new PageReadListener<FacilitiesFileDTO>(dataList -> { |
|
|
|
|
dataList.forEach( demoData -> { |
|
|
|
|
log.info(dataList.size()+"======================"); |
|
|
|
|
// for (FacilitiesFileDTO demoData : dataList) {
|
|
|
|
|
Facilities facilities = new Facilities(); |
|
|
|
|
facilities.setName(demoData.getName()); |
|
|
|
@ -181,11 +202,13 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
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()); |
|
|
|
|
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda() |
|
|
|
|
.like(StringUtils.isNotBlank(demoData.getClassify()), DictItem::getLabel, demoData.getClassifyTwo()) |
|
|
|
|
.eq(DictItem::getType, "rim") |
|
|
|
|
); |
|
|
|
|
if(ObjectUtil.isNotNull(rim) ){ |
|
|
|
|
facilities.setType(rim.getValue()); |
|
|
|
|
facilities.setTypecn(rim.getLabel()); |
|
|
|
|
}else{ |
|
|
|
|
throw new BusinessException("没有该分类"); |
|
|
|
|
} |
|
|
|
@ -202,11 +225,11 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
|
|
|
|
|
facilitiesMapper.insertFacilities(facilities); |
|
|
|
|
}); |
|
|
|
|
})).sheet().headRowNumber(1).doRead(); |
|
|
|
|
return true; |
|
|
|
|
return 1; |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|