daixiantong пре 4 година
родитељ
комит
276fffa457
3 измењених фајлова са 32 додато и 0 уклоњено
  1. +9
    -0
      src/main/java/com/taauav/admin/controller/TauvWaterTrendController.java
  2. +6
    -0
      src/main/java/com/taauav/admin/service/ITauvWaterTrendService.java
  3. +17
    -0
      src/main/java/com/taauav/admin/service/impl/TauvWaterTrendServiceImpl.java

+ 9
- 0
src/main/java/com/taauav/admin/controller/TauvWaterTrendController.java Прегледај датотеку

@@ -87,4 +87,13 @@ public class TauvWaterTrendController extends BaseController
public Response importExcel(@RequestParam("file") MultipartFile file) {
return tauvWaterTrendService.importTrend(file);
}

/**
* 下载导入模板
* @return
*/
@GetMapping("/template")
public Response exportTemplate() {
return tauvWaterTrendService.getTemplate();
}
}

+ 6
- 0
src/main/java/com/taauav/admin/service/ITauvWaterTrendService.java Прегледај датотеку

@@ -26,4 +26,10 @@ public interface ITauvWaterTrendService extends IBaseService<TauvWaterTrend>
* @return
*/
Response getTrendList(Integer id);

/**
* 获取导入数据模板
* @return
*/
Response getTemplate();
}

+ 17
- 0
src/main/java/com/taauav/admin/service/impl/TauvWaterTrendServiceImpl.java Прегледај датотеку

@@ -11,6 +11,7 @@ import com.taauav.common.bean.Response;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.taauav.admin.mapper.TauvWaterTrendMapper;
import com.taauav.admin.entity.TauvWaterTrend;
@@ -18,6 +19,7 @@ import com.taauav.admin.service.ITauvWaterTrendService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
@@ -36,6 +38,10 @@ public class TauvWaterTrendServiceImpl extends BaseServiceImpl<TauvWaterTrendMap
private SysCityMapper cityMapper;
@Autowired
private TauvDriverMapper driverMapper;
@Value("${file.uploadFolder}")
private String uploadFolder;
@Value("${server.UPLOAD_URL}")
private String uploadUrl;

/**
* 导入Excel数据
@@ -185,4 +191,15 @@ public class TauvWaterTrendServiceImpl extends BaseServiceImpl<TauvWaterTrendMap
List<TauvWaterTrend> list = baseMapper.selectList(wrapper);
return response.success(list);
}

@Override
public Response getTemplate() {
String filename = "导入水环境趋势模拟数据模板.xlsx";
File filedir = new File(uploadFolder);
if (!filedir.isDirectory()) {
filedir.mkdirs();
}
String path = uploadFolder + "/" + filename;
return response.success(path.replace(uploadFolder, uploadUrl + "/upload/"));
}
}

Loading…
Откажи
Сачувај