162 lines
5.8 KiB
Java
162 lines
5.8 KiB
Java
package com.gunshi.project.hsz.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
import com.gunshi.core.annotation.Post;
|
|
import com.gunshi.core.result.R;
|
|
import com.gunshi.project.hsz.entity.dto.StZqrlBDto;
|
|
import com.gunshi.project.hsz.entity.vo.StZqrlBCount24Vo;
|
|
import com.gunshi.project.hsz.entity.vo.StZqrlBCountVo;
|
|
import com.gunshi.project.hsz.entity.vo.StZqrlBVo;
|
|
import com.gunshi.project.hsz.model.AttResBase;
|
|
import com.gunshi.project.hsz.model.StZqrlB;
|
|
import com.gunshi.project.hsz.service.AttResBaseService;
|
|
import com.gunshi.project.hsz.service.StStbprpBService;
|
|
import com.gunshi.project.hsz.service.StZqrlBService;
|
|
import com.gunshi.project.hsz.service.StZvarlBService;
|
|
import com.gunshi.project.hsz.common.validate.markers.Delete;
|
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
|
import com.gunshi.project.hsz.common.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 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.Date;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* 描述: 水位流量关系曲线表
|
|
* author: xusan
|
|
* date: 2024-07-08 17:40:37
|
|
*/
|
|
@Tag(name = "水位流量关系曲线表")
|
|
@RestController
|
|
@RequestMapping(value="/stZqrlB")
|
|
public class StZqrlBController {
|
|
|
|
@Autowired
|
|
private StZqrlBService service;
|
|
|
|
@Autowired
|
|
private AttResBaseService resBaseService;
|
|
|
|
@Autowired
|
|
private StStbprpBService stStbprpBService;
|
|
|
|
@Autowired
|
|
private StZvarlBService stZvarlBService;
|
|
|
|
|
|
@Post(path = "/flowList", summary = "曲线数据")
|
|
public R<List<StZqrlBVo>> flowList(@RequestBody StZqrlBDto obj) {
|
|
return R.ok(stStbprpBService.flowList(obj));
|
|
}
|
|
|
|
@GetMapping(path = "/count/{stcd}")
|
|
@Schema(description = "实时数据")
|
|
public R<StZqrlBCountVo> count(@Schema(name = "stcd") @PathVariable("stcd") Serializable stcd) {
|
|
return R.ok(stStbprpBService.count(stcd));
|
|
}
|
|
|
|
|
|
@GetMapping(path = "/count24/{stcd}")
|
|
public R<StZqrlBCount24Vo> count24(@Schema(name = "stcd") @PathVariable("stcd") Serializable stcd) {
|
|
return R.ok(stStbprpBService.count24(stcd));
|
|
}
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
@PostMapping("/insert")
|
|
public R<StZqrlB> insert(@Validated(Insert.class) @RequestBody StZqrlB dto) {
|
|
if (StringUtils.isNotBlank(dto.getResCode())){
|
|
AttResBase one = resBaseService.list().get(0);
|
|
// if (Objects.isNull(one)){
|
|
// throw new IllegalArgumentException("水库编码不存在");
|
|
// }
|
|
if (StringUtils.isBlank(dto.getStcd())){
|
|
dto.setStcd(one.getStcd());
|
|
}
|
|
}
|
|
if (StringUtils.isNotBlank(dto.getStcd()) && Objects.isNull(stStbprpBService.getById(dto.getStcd()))){
|
|
throw new IllegalArgumentException("测站编码不存在");
|
|
}
|
|
|
|
if (service.lambdaQuery()
|
|
.eq(StZqrlB::getStcd, dto.getStcd())
|
|
.eq(StZqrlB::getZ, dto.getZ())
|
|
.eq(StZqrlB::getQ, dto.getQ())
|
|
.count() > 0) {
|
|
throw new IllegalArgumentException("当前数据已存在");
|
|
}
|
|
dto.setId(IdWorker.getId());
|
|
dto.setModitime(new Date());
|
|
boolean result = service.save(dto);
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "修改")
|
|
@PostMapping("/update")
|
|
public R<StZqrlB> update(@Validated(Update.class) @RequestBody StZqrlB dto) {
|
|
if (StringUtils.isNotBlank(dto.getStcd()) && Objects.isNull(stStbprpBService.getById(dto.getStcd()))){
|
|
throw new IllegalArgumentException("测站编码不存在");
|
|
}
|
|
|
|
if (service.lambdaQuery()
|
|
.eq(StZqrlB::getStcd, dto.getStcd())
|
|
.eq(StZqrlB::getZ, dto.getZ())
|
|
.eq(StZqrlB::getQ, dto.getQ())
|
|
.ne(StZqrlB::getId,dto.getId())
|
|
.count() > 0) {
|
|
throw new IllegalArgumentException("当前数据已存在");
|
|
}
|
|
|
|
|
|
|
|
boolean result = service.lambdaUpdate()
|
|
.set(StZqrlB::getZ, dto.getZ())
|
|
.set(StZqrlB::getQ, dto.getQ())
|
|
.eq(StZqrlB::getId, dto.getId())
|
|
.update();
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "删除")
|
|
@PostMapping("/del")
|
|
public R<Boolean> del(@Validated(Delete.class) @RequestBody StZqrlB dto) {
|
|
if (StringUtils.isNotBlank(dto.getStcd()) && Objects.isNull(stStbprpBService.getById(dto.getStcd()))){
|
|
throw new IllegalArgumentException("测站编码不存在");
|
|
}
|
|
if (service.lambdaQuery()
|
|
.eq(StZqrlB::getId, dto.getId())
|
|
.count() == 0) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
return R.ok(service.lambdaUpdate()
|
|
.eq(StZqrlB::getId, dto.getId())
|
|
.remove() );
|
|
}
|
|
|
|
@Operation(summary = "列表")
|
|
@PostMapping("/list")
|
|
public R<List<StZqrlB>> list(@RequestBody StZqrlB dto) {
|
|
LambdaQueryChainWrapper<StZqrlB> q = service.lambdaQuery().orderByAsc(StZqrlB::getZ);
|
|
// String stcd = dto.getStcd();
|
|
// if (StringUtils.isNotBlank(stcd)){
|
|
// q.eq(StZqrlB::getStcd, stcd);
|
|
// }
|
|
return R.ok(q.list());
|
|
}
|
|
|
|
// @Operation(summary = "分页")
|
|
// @PostMapping("/page")
|
|
public R<List<StZqrlB>> page() {
|
|
return R.ok(service.page(null,null));
|
|
}
|
|
|
|
} |