2024-01-25 16:02:16 +08:00
|
|
|
package com.gunshi.project.xyt.controller;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.gunshi.core.result.R;
|
|
|
|
|
import com.gunshi.project.xyt.model.StWaterQualityR;
|
|
|
|
|
import com.gunshi.project.xyt.service.WaterQualityService;
|
|
|
|
|
import com.gunshi.project.xyt.so.WaterQualityPageSo;
|
|
|
|
|
import com.gunshi.project.xyt.validate.markers.QueryPage;
|
|
|
|
|
import com.gunshi.project.xyt.validate.markers.QueryTimeRange;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Description:
|
|
|
|
|
* Created by xusan on 2024/1/23
|
|
|
|
|
*
|
|
|
|
|
* @author xusan
|
|
|
|
|
* @version 1.0
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Tag(name = "水质整编接口-controller", description = "水质整编接口")
|
|
|
|
|
@Data
|
|
|
|
|
@RequestMapping("/waterQuality")
|
|
|
|
|
public class WaterQualityController {
|
|
|
|
|
|
|
|
|
|
private final WaterQualityService waterqualityService;
|
|
|
|
|
|
|
|
|
|
// @Operation(summary = "新增水质监测数据")
|
|
|
|
|
// @ApiResponses(value = {
|
|
|
|
|
// @ApiResponse(responseCode = "200",description = "成功")
|
|
|
|
|
// })
|
|
|
|
|
// @PostMapping("/add")
|
|
|
|
|
// public R<String> add(@RequestBody @Validated StWaterQualityR organization){
|
|
|
|
|
// return R.ok(waterqualityService.add(organization));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Operation(summary = "更新水质监测数据")
|
|
|
|
|
// @ApiResponses(value = {
|
|
|
|
|
// @ApiResponse(responseCode = "200",description = "成功")
|
|
|
|
|
// })
|
|
|
|
|
// @PostMapping("/update")
|
|
|
|
|
// public R<String> update(@RequestBody @Validated StWaterQualityR organization){
|
|
|
|
|
// return R.ok(waterqualityService.update(organization));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Operation(summary = "根据id删除水质监测数据")
|
|
|
|
|
// @Parameter(name = "id", description = "水质监测数据id")
|
|
|
|
|
// @DeleteMapping("/delete")
|
|
|
|
|
// public R<String> delete(@RequestParam("id") String orgCode){
|
|
|
|
|
// return R.ok(waterqualityService.delete(orgCode));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "水质监测数据分页查询")
|
|
|
|
|
@PostMapping("/page")
|
|
|
|
|
public R<Page<StWaterQualityR>> page(
|
2024-01-26 14:06:29 +08:00
|
|
|
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody
|
2024-01-25 16:02:16 +08:00
|
|
|
WaterQualityPageSo waterQualityPageSo
|
|
|
|
|
) {
|
|
|
|
|
return R.ok(waterqualityService.page(waterQualityPageSo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "水质监测数据导出")
|
2024-01-26 09:31:50 +08:00
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(
|
2024-01-26 14:06:29 +08:00
|
|
|
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody
|
2024-01-26 09:31:50 +08:00
|
|
|
WaterQualityPageSo waterQualityPageSo, HttpServletResponse response) {
|
2024-01-25 16:02:16 +08:00
|
|
|
waterqualityService.export(waterQualityPageSo, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "水质监测数据导入")
|
2024-01-26 09:31:50 +08:00
|
|
|
@PostMapping("/import")
|
2024-01-26 14:38:30 +08:00
|
|
|
public R<Boolean> importExcel(@RequestParam("file") MultipartFile file) {
|
2024-01-25 16:02:16 +08:00
|
|
|
if (file.isEmpty()) {
|
2024-01-26 14:38:30 +08:00
|
|
|
return R.error(400, "请选择上传文件",false);
|
2024-01-25 16:02:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
return R.ok( waterqualityService.importExcel(file));
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
2024-01-26 14:38:30 +08:00
|
|
|
return R.error(500, "文件上传失败: " + e.getMessage(),false);
|
2024-01-25 16:02:16 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|