liusuyi
2026-05-30 f4f4fc53260eb67483dce406a963628273786a61
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package com.ard.work.point.well.controller;
 
import java.util.List;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletResponse;
 
import com.ard.common.core.constant.DeviceConstants;
import com.ard.common.core.domain.R;
import com.ard.common.security.annotation.InnerAuth;
import com.ard.common.security.utils.SecurityUtils;
import com.ard.work.utils.gis.GisUtil;
import com.ard.work.api.domian.Point;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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.ard.common.log.annotation.Log;
import com.ard.common.log.enums.BusinessType;
import com.ard.common.security.annotation.RequiresPermissions;
import com.ard.work.point.well.service.IArdWellService;
import com.ard.common.core.web.controller.BaseController;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.common.core.utils.poi.ExcelUtil;
import com.ard.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import com.ard.work.api.domian.ArdWell;
/**
 * 井管理Controller
 *
 * @author liusuyi
 * @date 2024-09-07
 */
@Tag(name = "井管理")
@RestController
@RequestMapping("/well")
@Slf4j
public class ArdWellController extends BaseController {
 
    @Autowired
    private IArdWellService ardWellService;
 
    /**
     * 查询井管理列表
     */
    @Operation(summary = "查询井管理列表")
    @RequiresPermissions("point:well:list")
    @GetMapping("/list")
    public TableDataInfo list(ArdWell ardWell) {
        startPage();
        List<ArdWell> list = ardWellService.selectArdWellList(ardWell);
        return getDataTable(list);
    }
 
    /**
     * 查询井管理列表
     */
    @InnerAuth
    @PostMapping(value = "/list/rpc")
    public R<List<ArdWell>>  listRpc(@RequestBody ArdWell ardWell) {
        List<ArdWell> list = ardWellService.selectArdWellList(ardWell);
        return R.ok(list);
    }
 
    /**
     * 导出井管理列表
     */
    @Operation(summary = "导出井管理列表")
    @RequiresPermissions("point:well:export")
    @Log(title = "井管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArdWell ardWell) {
        List<ArdWell> list = ardWellService.selectArdWellList(ardWell);
        ExcelUtil<ArdWell> util = new ExcelUtil<ArdWell>(ArdWell.class);
        util.exportExcel(response, list, "井管理数据");
    }
 
    /**
     * 获取井管理详细信息
     */
    @Operation(summary = "获取井管理详细信息")
    @RequiresPermissions("point:well:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(ardWellService.selectArdWellById(id));
    }
 
    /**
     * 获取井管理详细信息
     */
    @InnerAuth
    @GetMapping(value = "/{id}/rpc")
    public  R<ArdWell> getInfoRpc(@PathVariable("id") String id) {
        return R.ok(ardWellService.selectArdWellById(id));
    }
 
    /**
     * 新增井管理
     */
    @Operation(summary = "新增井管理")
    @RequiresPermissions("point:well:add")
    @Log(title = "井管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArdWell ardWell) {
        if (DeviceConstants.NOT_UNIQUE.equals(ardWellService.checkWellIdUnique(ardWell))) {
            return error("新增井号'" + ardWell.getWellId()  + "'失败,井号已存在");
        }
        return toAjax(ardWellService.insertArdWell(ardWell));
    }
 
    /**
     * 修改井管理
     */
    @Operation(summary = "修改井管理")
    @RequiresPermissions("point:well:edit")
    @Log(title = "井管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArdWell ardWell) {
        if (DeviceConstants.NOT_UNIQUE.equals(ardWellService.checkWellIdUnique(ardWell))) {
            return error("修改井号'" + ardWell.getWellId()  + "'失败,井号已存在");
        }
        return toAjax(ardWellService.updateArdWell(ardWell));
    }
 
    /**
     * 删除井管理
     */
    @Operation(summary = "删除井管理")
    @RequiresPermissions("point:well:remove")
    @Log(title = "井管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(ardWellService.deleteArdWellByIds(ids));
    }
 
 
    /**
     * 导入井管理
     */
    @Operation(summary = "导入井管理")
    @RequiresPermissions("point:well:import")
    @Log(title = "井管理", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
        ExcelUtil<ArdWell> util = new ExcelUtil<ArdWell>(ArdWell.class);
        List<ArdWell> wellList = util.importExcel(file.getInputStream());
        String operName = SecurityUtils.getLoginUser().getUsername();
        String message = ardWellService.importWell(wellList, updateSupport, operName);
        return success(message);
    }
 
    @Operation(summary = "井导入模板")
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<ArdWell> util = new ExcelUtil<ArdWell>(ArdWell.class);
        util.importTemplateExcel(response, "井数据");
    }
 
    @Operation(summary = "查询范围内的井")
    @PostMapping("/getWellListByPolygon")
    AjaxResult getWellListByPolygon(@RequestBody List<Point> points) {
        List<ArdWell> ardWells = ardWellService.selectArdWellList(new ArdWell()).stream()
                .filter(well -> well.getLongitude() != null && well.getLatitude() != null)
                .filter(well -> GisUtil.isInPolygon(new Point(well.getLongitude(), well.getLatitude(),null), points))
                .collect(Collectors.toList());
        return AjaxResult.success(ardWells);
    }
 
    @Operation(summary = "查询设备运行状态")
    @RequiresPermissions("point:well:dataYj8")
    @GetMapping("/getRTUDataYJ8")
    public AjaxResult getRTUDataYJ8(String wellId){
        return AjaxResult.success(ardWellService.getRTUDataYJ8(wellId));
    }
}