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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package cn.gistack.sm.sjztmd.controller;
 
import cn.gistack.sm.sjztmd.entity.AttResStagCapDics;
import cn.gistack.sm.sjztmd.excel.AttResStagCapDiscExcel;
import cn.gistack.sm.sjztmd.excel.AttResStagCapDiscImport;
import cn.gistack.sm.sjztmd.service.IAttResStagCapDicsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.excel.util.ExcelUtil;
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 javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
 
/**
 * @ClassName AttResStagCapDicsController
 * @author zhongrj
 * @Date 2023/09/04
 */
@Slf4j
@Api(tags = "中台水库库容数据信息填报")
@RestController
@RequestMapping("/sjztmd/attResStagCapDics")
@AllArgsConstructor
public class AttResStagCapDicsController {
 
    private final IAttResStagCapDicsService attResStagCapDicsService;
 
 
    /**
     * 查询水库填报详情信息
     * @param resGuid
     * @return
     */
    @ApiOperation(value = "中台水库-查询水库填报详情信息", notes = "中台水库-查询水库填报详情信息")
    @GetMapping(value = "/getDetailByGuid")
    public R getDetailByCode(String resGuid) {
        List<AttResStagCapDics> attResBase = attResStagCapDicsService.getDetailByGuid(resGuid);
        return R.data(attResBase);
    }
 
    /**
     * 新增
     * @param attResStagCapDics
     * @return
     */
    @ApiOperation(value = "水库信息-新增", notes = "水库信息-新增")
    @PostMapping(value = "/save")
    public R save(@RequestBody AttResStagCapDics attResStagCapDics) {
        Date date = new Date();
        attResStagCapDics.setCreateTime(date);
        attResStagCapDics.setUpdateTime(date);
        attResStagCapDics.setCollectTime(date);
        attResStagCapDics.setSysResource("手工录入");
        return R.status(attResStagCapDicsService.save(attResStagCapDics));
    }
 
    /**
     * 批量新增
     * @param attResStagCapDicsList
     * @return
     */
    @ApiOperation(value = "水库信息-批量新增", notes = "水库信息-批量新增")
    @PostMapping(value = "/batchSave")
    public R batchSave(@RequestBody List<AttResStagCapDics> attResStagCapDicsList) {
        for (AttResStagCapDics attResStagCapDics : attResStagCapDicsList) {
            Date date = new Date();
            attResStagCapDics.setCreateTime(date);
            attResStagCapDics.setUpdateTime(date);
            attResStagCapDics.setCollectTime(date);
            attResStagCapDics.setSysResource("手工录入");
        }
        return R.status(attResStagCapDicsService.saveBatch(attResStagCapDicsList));
    }
 
    /**
     * 编辑
     * @param attResStagCapDics
     * @return
     */
    @ApiOperation(value = "水库信息-编辑", notes = "水库信息-编辑")
    @PostMapping(value = "/edit")
    public R edit(@RequestBody AttResStagCapDics attResStagCapDics) {
        Date date = new Date();
        attResStagCapDics.setUpdateTime(date);
        return R.status(attResStagCapDicsService.updateById(attResStagCapDics));
    }
 
    /**
     * 删除
     * @param ids
     * @return
     */
    @ApiOperation(value = "水库信息-删除", notes = "水库信息-删除")
    @PostMapping(value = "/remove")
    public R remove(@RequestParam  String ids) {
        return R.status(attResStagCapDicsService.removeByIds(Arrays.asList(ids.split(","))));
    }
 
    /**
     * 导入库容
     */
    @PostMapping("import-attResStagCapDics")
    public R importUser(MultipartFile file,String resGuid) {
        AttResStagCapDiscImport attResStagCapDiscImport = new AttResStagCapDiscImport(attResStagCapDicsService,resGuid);
        ExcelUtil.save(file, attResStagCapDiscImport, AttResStagCapDiscExcel.class);
        return R.success("操作成功");
    }
 
    /**
     * 导出库容模板
     */
    @GetMapping("export-attResStagCapDics-template")
    public void exportAttResStagCapDicsTemplate(HttpServletResponse response) {
        List<AttResStagCapDiscExcel> list = new ArrayList<>();
        ExcelUtil.export(response, "水库库容数据" + DateUtil.time(), "水库库容数据表", list, AttResStagCapDiscExcel.class);
    }
 
}