zhangjian
2023-05-29 9763c7a6ed43a60c099d49cc149c86652fbb3cfa
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package com.ruoyi.alarmpoints.well.controller;
 
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
 
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 井管理Controller
 *
 * @author 刘苏义
 * @date 2023-03-07
 */
@RestController
@RequestMapping("/alarmpoints/well")
@Api(tags = "井管理接口")
public class ArdAlarmpointsWellController extends BaseController {
    @Resource
    private IArdAlarmpointsWellService ardAlarmpointsWellService;
 
    /**
     * 查询井管理列表
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:list')")
    @GetMapping("/list")
    @ApiOperation("查询井列表")
    public TableDataInfo list(ArdAlarmpointsWell ardAlarmpointsWell) {
        startPage();
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.selectArdAlarmpointsWellList(ardAlarmpointsWell);
        return getDataTable(list);
    }
 
    /**
     * 导出井管理列表
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:export')")
    @Log(title = "井管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出井列表")
    public void export(HttpServletResponse response, ArdAlarmpointsWell ardAlarmpointsWell) {
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.selectArdAlarmpointsWellList(ardAlarmpointsWell);
        ExcelUtil<ArdAlarmpointsWell> util = new ExcelUtil<ArdAlarmpointsWell>(ArdAlarmpointsWell.class);
        util.exportExcel(response, list, "井管理数据");
    }
 
    /**
     * 获取井管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取井详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(ardAlarmpointsWellService.selectArdAlarmpointsWellById(id));
    }
 
    /**
     * 新增井管理
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:add')")
    @Log(title = "井管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增井")
    public AjaxResult add(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) {
        return toAjax(ardAlarmpointsWellService.insertArdAlarmpointsWell(ardAlarmpointsWell));
    }
 
    /**
     * 修改井管理
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:edit')")
    @Log(title = "井管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改井")
    public AjaxResult edit(@RequestBody ArdAlarmpointsWell ardAlarmpointsWell) {
        return toAjax(ardAlarmpointsWellService.updateArdAlarmpointsWell(ardAlarmpointsWell));
    }
 
    /**
     * 删除井管理
     */
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:remove')")
    @Log(title = "井管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除井")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(ardAlarmpointsWellService.deleteArdAlarmpointsWellByIds(ids));
    }
 
    @Log(title = "井管理", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('alarmpoints:well:import')")
    @PostMapping("/importData")
    @ApiOperation("导入井")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
        ExcelUtil<ArdAlarmpointsWell> util = new ExcelUtil<ArdAlarmpointsWell>(ArdAlarmpointsWell.class);
        List<ArdAlarmpointsWell> userList = util.importExcel(file.getInputStream());
        String operName = getUsername();
        String message = ardAlarmpointsWellService.importUser(userList, updateSupport, operName);
        return success(message);
    }
 
    @PostMapping("/importTemplate")
    @ApiOperation("井导入模板")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<ArdAlarmpointsWell> util = new ExcelUtil<ArdAlarmpointsWell>(ArdAlarmpointsWell.class);
        util.importTemplateExcel(response, "井数据");
    }
 
    /**
     * 井选项数据
     */
    @GetMapping("/options")
    @ApiOperation("井选项数据")
    public List options(ArdAlarmpointsWell ardAlarmpointsWell) {
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellService.selectArdAlarmpointsWellByWellIdLike(ardAlarmpointsWell);
        List options = new ArrayList();
        for (ArdAlarmpointsWell item : list) {
            Map option = new HashMap();
            option.put("value", item.getId());
            option.put("label", item.getWellId());
            option.put("description", item.getOilProduction());
            options.add(option);
        }
        return options;
    }
}