guoshilong
2024-03-28 419882f64115b66112f03c96892cf2d3a4f298a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package cn.gistack.sm.sjztdw.controller;
 
import cn.gistack.sm.sjztdw.excel.DbExcel;
import cn.gistack.sm.sjztdw.excel.DbExcelImport;
import cn.gistack.sm.sjztdw.service.IDbPersonReportService;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 大坝人工上报相关接口
 */
@RestController
@RequestMapping("/sjztdw/dbReport")
@AllArgsConstructor
public class DbPersonReportController extends BladeController {
 
    private IDbPersonReportService dbPersonReportService;
 
    /**
     * 导入模板
     */
    @GetMapping("export-template")
    public void exportTemplate(HttpServletResponse response) {
        List<DbExcel> list = new ArrayList<>();
 
        for (int i = 0; i < 10; i++) {
            DbExcel dbExcel = new DbExcel();
            dbExcel.setMonitorDate(StringUtil.format("2024-03-{}",10+i));
            list.add(dbExcel);
        }
        ExcelUtil.export(response, "人工上报模板", "人工上报数据表", list, DbExcel.class);
    }
 
 
    /**
     * 导入数据
     * @param file 导入excel
     * @param resGuid 水库id
     * @param ch 断面
     * @return
     */
    @PostMapping("import-data")
    public R importData(MultipartFile file,String resGuid,String ch) {
        DbExcelImport dbExcelImport = new DbExcelImport(dbPersonReportService,resGuid,ch);
        ExcelUtil.save(file, dbExcelImport, DbExcel.class);
        return R.success("操作成功");
    }
 
 
 
 
}