gunshi-project-ss/src/main/java/com/gunshi/project/hsz/controller/OsmoticShiftRController.java

116 lines
4.4 KiB
Java
Raw Normal View History

2025-07-17 15:26:39 +08:00
package com.gunshi.project.hsz.controller;
2024-07-08 17:47:02 +08:00
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
2024-07-08 17:47:02 +08:00
import com.gunshi.core.result.R;
2025-07-17 15:26:39 +08:00
import com.gunshi.project.hsz.entity.so.OsmoticDetailQuerySo;
import com.gunshi.project.hsz.entity.so.OsmoticQueryPageSo;
import com.gunshi.project.hsz.entity.so.OsmoticQuerySo;
import com.gunshi.project.hsz.entity.vo.*;
import com.gunshi.project.hsz.model.OsmoticShiftR;
import com.gunshi.project.hsz.service.OsmoticShiftRService;
import com.gunshi.project.hsz.validate.markers.Insert;
import com.gunshi.project.hsz.validate.markers.Update;
2024-07-08 17:47:02 +08:00
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
2024-07-15 10:14:51 +08:00
import jakarta.servlet.http.HttpServletResponse;
2024-07-08 17:47:02 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
2024-07-08 17:47:02 +08:00
/**
* :
* author: xusan
* date: 2024-07-08 17:40:37
*/
@Tag(name = "位移监测记录表")
@RestController
@RequestMapping(value="/osmoticShiftR")
public class OsmoticShiftRController {
@Autowired
private OsmoticShiftRService service;
@Operation(summary = "新增")
@PostMapping("/insert")
public R<OsmoticShiftR> insert(@Validated(Insert.class) @RequestBody OsmoticShiftR dto) {
// dto.setTm(new Date());
2024-07-08 17:47:02 +08:00
boolean result = service.save(dto);
return R.ok(result ? dto : null);
}
@Operation(summary = "修改")
@PostMapping("/update")
public R<OsmoticShiftR> update(@Validated(Update.class) @RequestBody OsmoticShiftR dto) {
LambdaUpdateWrapper<OsmoticShiftR> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(OsmoticShiftR::getStationCode, dto.getStationCode())
.eq(OsmoticShiftR::getTm, dto.getTm())
.set(OsmoticShiftR::getX, dto.getX())
.set(OsmoticShiftR::getY, dto.getY())
.set(OsmoticShiftR::getH, dto.getH());
boolean update = service.update(null, wrapper);
return R.ok(update ? dto : null);
2024-07-08 17:47:02 +08:00
}
@Operation(summary = "删除")
@GetMapping("/del/{id}/{tm}")
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id,@Schema(name = "tm") @PathVariable("tm") Serializable tm) {
if(Objects.isNull(id) || Objects.isNull(tm)){
return R.ok(false);
}
QueryWrapper<OsmoticShiftR> wrapper = new QueryWrapper<>();
wrapper.eq("station_code", id).eq("tm", tm);
return R.ok(service.remove(wrapper));
2024-07-08 17:47:02 +08:00
}
@Operation(summary = "列表")
@PostMapping("/list")
public R<List<OsmoticShiftR>> list() {
return R.ok(service.lambdaQuery().list());
}
@Operation(summary = "分页")
@PostMapping("/page")
public R<Page<OsmoticShiftR>> page(@RequestBody OsmoticQueryPageSo osmoticQueryPageSo) {
return R.ok(service.queryPage(osmoticQueryPageSo));
2024-07-08 17:47:02 +08:00
}
@Operation(summary = "年度位移统计(表格)")
@PostMapping("/year/stat")
public R<List<OsmoticShiftVo>> yearStat(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
return R.ok(service.yearStat(osmoticQuerySo));
}
@Operation(summary = "年度位移统计(全年度特征值统计)")
@PostMapping("/year/stat/value")
public R<List<OsmoticChartVo>> yearStatValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
return R.ok(service.yearStatValue(osmoticQuerySo));
}
2024-07-15 10:14:51 +08:00
@Operation(summary = "年度位移统计导出")
@PostMapping( "/year/stat/export")
public void yearStatExport(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
service.yearStatExport(osmoticQuerySo,response);
}
@Operation(summary = "布置图-位移监测")
@GetMapping("/list/value")
public R<List<OsmoticShiftListVo>> listValue() {
return R.ok(service.listValue());
}
@Operation(summary = "布置图-按测站查询位移监测数据")
@PostMapping("/detail/value")
public R<List<OsmoticShiftValueVo>> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) {
return R.ok(service.detailValue(so));
}
2024-07-08 17:47:02 +08:00
}