109 lines
3.6 KiB
Java
109 lines
3.6 KiB
Java
package com.gunshi.project.hsz.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.gunshi.core.result.R;
|
|
import com.gunshi.project.hsz.common.model.so.JcskSyBPageSo;
|
|
import com.gunshi.project.hsz.common.model.vo.HomeJcskSYBVo;
|
|
import com.gunshi.project.hsz.common.model.JcskSyB;
|
|
import com.gunshi.project.hsz.service.JcskSyBService;
|
|
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.time.LocalDateTime;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
@Tag(name = "测压管表")
|
|
@RestController
|
|
@RequestMapping(value="/osmoticPressDevice")
|
|
public class JcskSyBController extends AbstractCommonFileController {
|
|
|
|
|
|
@Autowired
|
|
private JcskSyBService service;
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
@PostMapping("/insert")
|
|
public R<JcskSyB> insert(@Validated(Insert.class) @RequestBody JcskSyB dto) {
|
|
if (Objects.nonNull(service.getById(dto.getMpcd()))) {
|
|
throw new IllegalArgumentException("当前编号已存在");
|
|
}
|
|
dto.setDtuptm(LocalDateTime.now());
|
|
boolean result = service.save(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode());
|
|
// }
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "修改")
|
|
@PostMapping("/update")
|
|
public R<JcskSyB> update(@Validated(Update.class) @RequestBody JcskSyB dto) {
|
|
if (Objects.isNull(service.getById(dto.getMpcd()))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
dto.setDtuptm(LocalDateTime.now());
|
|
boolean result = service.updateById(dto);
|
|
// if (result){
|
|
// fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode());
|
|
// }
|
|
return R.ok(result ? dto : null);
|
|
}
|
|
|
|
@Operation(summary = "删除")
|
|
@GetMapping("/del/{id}")
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
|
if (Objects.isNull(service.getById(id))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
return R.ok(service.removeById(id));
|
|
}
|
|
|
|
|
|
@Operation(summary = "分页")
|
|
@PostMapping("/page")
|
|
public R<Page<JcskSyB>> page(@RequestBody @Validated JcskSyBPageSo page) {
|
|
return R.ok(service.pageQuery(page));
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "详情和监测数据查询")
|
|
@PostMapping("/getDetailsAndMonitoringDataList")
|
|
public R<List<HomeJcskSYBVo>> getDetailsAndMonitoringDataList() {
|
|
return R.ok(service.getDetailsAndMonitoringDataList());
|
|
}
|
|
|
|
@Operation(summary = "根据id查询详细数据")
|
|
@GetMapping("/getDetailsById")
|
|
public R<HomeJcskSYBVo> getDetailsById(@RequestParam(name = "id") String id) {
|
|
HomeJcskSYBVo byId = service.getDetailsById(id);
|
|
return R.ok(byId);
|
|
}
|
|
|
|
|
|
@Operation(summary = "列表")
|
|
@PostMapping("/list")
|
|
public R<List<JcskSyB>> list() {
|
|
List<JcskSyB> list = service.lambdaQuery().list();
|
|
list.stream().forEach(item -> {
|
|
item.setStationCode(item.getDvcd());
|
|
});
|
|
return R.ok(list);
|
|
}
|
|
|
|
@Override
|
|
public String getGroupId() {
|
|
return "OsmoticPressDevice";
|
|
}
|
|
}
|