glj-代码提交
This commit is contained in:
parent
a4804c6324
commit
88006628d1
|
@ -90,7 +90,7 @@ public class NewsController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 导入供应商模板
|
||||
* 导入
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.springblade.core.mp.support.Query;
|
|||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -76,4 +77,19 @@ public class RemoteSensingSourceDataController {
|
|||
public R approval(@RequestBody RemoteSensingSourceData remoteSensingSourceData){
|
||||
return R.status(remoteSensingSourceDataService.updateById(remoteSensingSourceData));
|
||||
}
|
||||
|
||||
@PostMapping("/addRemoteSensingSourceData")
|
||||
public R addRemoteSensingSourceData(@RequestBody RemoteSensingSourceData remoteSensingSourceData){
|
||||
return R.status(remoteSensingSourceDataService.save(remoteSensingSourceData));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping({"/importTemplate"})
|
||||
public R fileExcelUpload(@RequestParam("file") MultipartFile file, @RequestParam("disasterId") Long disasterId) {
|
||||
return R.data(remoteSensingSourceDataService.importTemplate(file,disasterId));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.kening.vordm.entity.EntityData;
|
||||
import com.kening.vordm.entity.RemoteSensingSourceData;
|
||||
import com.kening.vordm.vo.GroupByUse;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -20,4 +22,5 @@ public interface RemoteSensingSourceDataService extends IService<RemoteSensingSo
|
|||
|
||||
IPage<RemoteSensingSourceData> getRemoteSensingSourceDataByCondition(IPage<Object> page, RemoteSensingSourceData remoteSensingSourceData);
|
||||
|
||||
R importTemplate(MultipartFile file, Long disasterId);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,35 @@
|
|||
package com.kening.vordm.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.kening.vordm.entity.News;
|
||||
import com.kening.vordm.entity.RemoteSensingSourceData;
|
||||
import com.kening.vordm.mapper.RemoteSensingSourceDataMapper;
|
||||
import com.kening.vordm.service.RemoteSensingSourceDataService;
|
||||
import com.kening.vordm.vo.productResolutionVo;
|
||||
import org.springblade.common.utils.ExcelCellUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @author G1393
|
||||
* @description 针对表【remote_sensing_source_data(遥感影像源数据)】的数据库操作Service实现
|
||||
* @createDate 2023-04-04 15:54:31
|
||||
*/
|
||||
* @author G1393
|
||||
* @description 针对表【remote_sensing_source_data(遥感影像源数据)】的数据库操作Service实现
|
||||
* @createDate 2023-04-04 15:54:31
|
||||
*/
|
||||
@Service
|
||||
public class RemoteSensingSourceDataServiceImpl extends ServiceImpl<RemoteSensingSourceDataMapper, RemoteSensingSourceData>
|
||||
implements RemoteSensingSourceDataService {
|
||||
implements RemoteSensingSourceDataService {
|
||||
|
||||
@Override
|
||||
public List<RemoteSensingSourceData> getRemoteSensingSourceData(String disasterType, String disasterCountry, String disasterTime) {
|
||||
|
@ -34,20 +41,20 @@ implements RemoteSensingSourceDataService {
|
|||
List<productResolutionVo> productResolutionVos = remoteSensingSourceData.getProductResolutionVos();
|
||||
String satelliteCodeList = remoteSensingSourceData.getSatelliteCodeList();
|
||||
List<String> result = new ArrayList<>();
|
||||
if (satelliteCodeList!=null) {
|
||||
if (satelliteCodeList != null) {
|
||||
result = Arrays.asList(satelliteCodeList.split(","));
|
||||
remoteSensingSourceData.setSatelliteCodeListNew(result);
|
||||
}
|
||||
IPage<RemoteSensingSourceData> remoteSensingSourceDataByCondition = new Page<>();
|
||||
|
||||
if (productResolutionVos != null && !productResolutionVos.isEmpty()){
|
||||
if (productResolutionVos != null && !productResolutionVos.isEmpty()) {
|
||||
List<RemoteSensingSourceData> remoteSensingSourceData1 = new ArrayList<>();
|
||||
|
||||
productResolutionVos.stream().forEach(productResolutionVo -> {
|
||||
if (Objects.equals(productResolutionVo.getProductResolutionMax(), new Double("1000"))){
|
||||
if (Objects.equals(productResolutionVo.getProductResolutionMax(), new Double("1000"))) {
|
||||
remoteSensingSourceData.setProductResolutionMax(null);
|
||||
remoteSensingSourceData.setProductResolutionMin(productResolutionVo.getProductResolutionMin());
|
||||
}else {
|
||||
} else {
|
||||
remoteSensingSourceData.setProductResolutionMin(productResolutionVo.getProductResolutionMin());
|
||||
remoteSensingSourceData.setProductResolutionMax(productResolutionVo.getProductResolutionMax());
|
||||
}
|
||||
|
@ -57,9 +64,81 @@ implements RemoteSensingSourceDataService {
|
|||
|
||||
remoteSensingSourceDataByCondition.setRecords(remoteSensingSourceData1);
|
||||
remoteSensingSourceDataByCondition.setTotal(remoteSensingSourceData1.size());
|
||||
}else {
|
||||
} else {
|
||||
remoteSensingSourceDataByCondition = this.baseMapper.getRemoteSensingSourceDataByCondition(remoteSensingSourceData, page);
|
||||
}
|
||||
return remoteSensingSourceDataByCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R importTemplate(MultipartFile file, Long disasterId) {
|
||||
List content;
|
||||
try {
|
||||
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
||||
content = reader.read();
|
||||
} catch (Exception var30) {
|
||||
return R.fail("上传文件格式解析错误");
|
||||
}
|
||||
if (CollectionUtil.isEmpty(content)) {
|
||||
return R.fail("文件内容为空!");
|
||||
}
|
||||
for (int i = 0; i < content.size(); ++i) {
|
||||
List<Object> row = (List) content.get(i);
|
||||
if (i != 0) {
|
||||
if (CollUtil.isNotEmpty(row)) {
|
||||
String thumbnail_link = ExcelCellUtil.strHandle(row.get(0));
|
||||
String product_level = ExcelCellUtil.strHandle(row.get(1));
|
||||
String product_serial_num = ExcelCellUtil.strHandle(row.get(2));
|
||||
String product_time = ExcelCellUtil.strHandle(row.get(3));
|
||||
String product_resolution = ExcelCellUtil.strHandle(row.get(4));
|
||||
String cloud_cover = ExcelCellUtil.strHandle(row.get(5));
|
||||
String satellite_code = ExcelCellUtil.strHandle(row.get(6));
|
||||
String upper_left_lat = ExcelCellUtil.strHandle(row.get(7));
|
||||
String upper_left_lon = ExcelCellUtil.strHandle(row.get(8));
|
||||
String upper_right_lat = ExcelCellUtil.strHandle(row.get(9));
|
||||
String upper_right_lon = ExcelCellUtil.strHandle(row.get(10));
|
||||
String view_center_lat = ExcelCellUtil.strHandle(row.get(11));
|
||||
String view_center_lon = ExcelCellUtil.strHandle(row.get(12));
|
||||
String lower_right_lat = ExcelCellUtil.strHandle(row.get(13));
|
||||
String lower_right_lon = ExcelCellUtil.strHandle(row.get(14));
|
||||
String lower_left_lat = ExcelCellUtil.strHandle(row.get(15));
|
||||
String lower_left_lon = ExcelCellUtil.strHandle(row.get(16));
|
||||
String source_organization = ExcelCellUtil.strHandle(row.get(17));
|
||||
RemoteSensingSourceData remoteSensingSourceData = new RemoteSensingSourceData();
|
||||
remoteSensingSourceData.setThumbnailLink(thumbnail_link);
|
||||
remoteSensingSourceData.setProductLevel(product_level);
|
||||
remoteSensingSourceData.setProductSerialNum(product_serial_num);
|
||||
if (product_time != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date dateStr = null;
|
||||
try {
|
||||
dateStr = sdf.parse(product_time);
|
||||
} catch (ParseException e) {
|
||||
return R.fail("时间格式错误");
|
||||
}
|
||||
remoteSensingSourceData.setProductTime(dateStr);
|
||||
}
|
||||
remoteSensingSourceData.setProductResolution(Double.parseDouble(product_resolution));
|
||||
remoteSensingSourceData.setCloudCover(Integer.parseInt(cloud_cover));
|
||||
remoteSensingSourceData.setSatelliteCode(satellite_code);
|
||||
remoteSensingSourceData.setUpperLeftLat(Double.parseDouble(upper_left_lat));
|
||||
remoteSensingSourceData.setUpperLeftLon(Double.parseDouble(upper_left_lon));
|
||||
remoteSensingSourceData.setUpperRightLat(Double.parseDouble(upper_right_lat));
|
||||
remoteSensingSourceData.setUpperRightLon(Double.parseDouble(upper_right_lon));
|
||||
remoteSensingSourceData.setViewCenterLat(Double.parseDouble(view_center_lat));
|
||||
remoteSensingSourceData.setViewCenterLon(Double.parseDouble(view_center_lon));
|
||||
remoteSensingSourceData.setLowerRightLat(Double.parseDouble(lower_right_lat));
|
||||
remoteSensingSourceData.setLowerRightLon(Double.parseDouble(lower_right_lon));
|
||||
remoteSensingSourceData.setLowerLeftLat(Double.parseDouble(lower_left_lat));
|
||||
remoteSensingSourceData.setLowerLeftLon(Double.parseDouble(lower_left_lon));
|
||||
remoteSensingSourceData.setSourceOrganization(source_organization);
|
||||
remoteSensingSourceData.setDisasterId(disasterId);
|
||||
remoteSensingSourceData.setCreateTime(new Date());
|
||||
remoteSensingSourceData.setStatus(3);
|
||||
this.baseMapper.insert(remoteSensingSourceData);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.data("上传成功!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue