package com.gunshi.project.hsz.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gunshi.core.result.R; 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; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; 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; /** * 描述: 位移监测记录表 * 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 insert(@Validated(Insert.class) @RequestBody OsmoticShiftR dto) { // dto.setTm(new Date()); boolean result = service.save(dto); return R.ok(result ? dto : null); } @Operation(summary = "修改") @PostMapping("/update") public R update(@Validated(Update.class) @RequestBody OsmoticShiftR dto) { LambdaUpdateWrapper 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); } @Operation(summary = "删除") @GetMapping("/del/{id}/{tm}") public R 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 wrapper = new QueryWrapper<>(); wrapper.eq("station_code", id).eq("tm", tm); return R.ok(service.remove(wrapper)); } @Operation(summary = "列表") @PostMapping("/list") public R> list() { return R.ok(service.lambdaQuery().list()); } @Operation(summary = "分页") @PostMapping("/page") public R> page(@RequestBody OsmoticQueryPageSo osmoticQueryPageSo) { return R.ok(service.queryPage(osmoticQueryPageSo)); } @Operation(summary = "年度位移统计(表格)") @PostMapping("/year/stat") public R> yearStat(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) { return R.ok(service.yearStat(osmoticQuerySo)); } @Operation(summary = "年度位移统计(全年度特征值统计)") @PostMapping("/year/stat/value") public R> yearStatValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) { return R.ok(service.yearStatValue(osmoticQuerySo)); } @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> listValue() { return R.ok(service.listValue()); } @Operation(summary = "布置图-按测站查询位移监测数据") @PostMapping("/detail/value") public R> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) { return R.ok(service.detailValue(so)); } }