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));
|
}
|
}
|