2025-07-17 15:26:39 +08:00
|
|
|
package com.gunshi.project.hsz.controller;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
2024-08-15 17:27:27 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
2024-08-19 11:25:25 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
2024-07-17 17:38:06 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
2024-08-15 17:27:27 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
2024-07-17 17:38:06 +08:00
|
|
|
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.GeneralDataPage;
|
|
|
|
|
import com.gunshi.project.hsz.entity.vo.ProfilePressTreeVo;
|
|
|
|
|
import com.gunshi.project.hsz.model.AttDamProfile;
|
|
|
|
|
import com.gunshi.project.hsz.service.AttDamProfileService;
|
|
|
|
|
import com.gunshi.project.hsz.service.FileAssociationsService;
|
2025-11-04 16:14:38 +08:00
|
|
|
import com.gunshi.project.hsz.common.validate.markers.Insert;
|
|
|
|
|
import com.gunshi.project.hsz.common.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-18 18:00:27 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
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;
|
2024-07-17 17:38:06 +08:00
|
|
|
import java.util.Objects;
|
2024-07-10 13:16:22 +08:00
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 监测断面信息表
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-07-08 17:40:37
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "监测断面信息表")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value="/attDamProfile")
|
2024-07-17 17:38:06 +08:00
|
|
|
public class AttDamProfileController extends AbstractCommonFileController{
|
2024-07-08 17:47:02 +08:00
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AttDamProfileService service;
|
|
|
|
|
|
2024-07-17 17:38:06 +08:00
|
|
|
@Autowired
|
|
|
|
|
private FileAssociationsService fileService;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public R<AttDamProfile> insert(@Validated(Insert.class) @RequestBody AttDamProfile dto) {
|
2024-07-18 18:00:27 +08:00
|
|
|
if (Objects.nonNull(service.getById(dto.getProfileCode()))) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前编号已存在");
|
2024-08-19 11:25:25 +08:00
|
|
|
}else{
|
|
|
|
|
dto.setProfileCode(String.valueOf(IdWorker.getId()));
|
2024-07-17 17:38:06 +08:00
|
|
|
}
|
2024-07-18 18:00:27 +08:00
|
|
|
if (StringUtils.isNotBlank(dto.getProfileName())){
|
|
|
|
|
if (service.lambdaQuery().eq(AttDamProfile::getProfileName,dto.getProfileName()).count() > 0) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前名称已存在");
|
2024-07-18 18:00:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.save(dto);
|
2024-07-17 17:38:06 +08:00
|
|
|
if (result){
|
|
|
|
|
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getProfileCode());
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改")
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
public R<AttDamProfile> update(@Validated(Update.class) @RequestBody AttDamProfile dto) {
|
2024-07-17 17:38:06 +08:00
|
|
|
if (Objects.isNull(service.getById(dto.getProfileCode()))) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
2024-07-17 17:38:06 +08:00
|
|
|
}
|
2024-07-18 18:00:27 +08:00
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getProfileName())){
|
|
|
|
|
if (service.lambdaQuery().eq(AttDamProfile::getProfileName,dto.getProfileName())
|
|
|
|
|
.ne(AttDamProfile::getProfileCode,dto.getProfileCode())
|
|
|
|
|
.count() > 0) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前名称已存在");
|
2024-07-18 18:00:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.updateById(dto);
|
2024-07-17 17:38:06 +08:00
|
|
|
if (result){
|
|
|
|
|
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getProfileCode());
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@GetMapping("/del/{id}")
|
|
|
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
2024-07-17 17:38:06 +08:00
|
|
|
if (Objects.isNull(service.getById(id))) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
2024-07-17 17:38:06 +08:00
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
return R.ok(service.removeById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "列表")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public R<List<AttDamProfile>> list() {
|
2025-11-03 16:47:35 +08:00
|
|
|
|
2025-03-27 14:22:45 +08:00
|
|
|
LambdaQueryWrapper<AttDamProfile> wq = new LambdaQueryWrapper();
|
|
|
|
|
wq.orderByAsc(AttDamProfile::getProfileCode);
|
|
|
|
|
List<AttDamProfile> list = service.list(wq);
|
|
|
|
|
return R.ok(list);
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-10 13:16:22 +08:00
|
|
|
@Operation(summary = "断面渗压树")
|
|
|
|
|
@PostMapping("/tree")
|
|
|
|
|
public R<List<ProfilePressTreeVo>> tree() {
|
|
|
|
|
return R.ok(service.tree());
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
@Operation(summary = "分页")
|
|
|
|
|
@PostMapping("/page")
|
2024-07-17 17:38:06 +08:00
|
|
|
public R<Page<AttDamProfile>> page(@RequestBody @Validated GeneralDataPage page) {
|
2024-08-15 17:27:27 +08:00
|
|
|
LambdaQueryWrapper<AttDamProfile> query = Wrappers.lambdaQuery();
|
|
|
|
|
|
2024-07-17 17:38:06 +08:00
|
|
|
if (ObjectUtils.isNotNull(page.getName())) {
|
|
|
|
|
query.like(AttDamProfile::getProfileName, page.getName());
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 18:00:27 +08:00
|
|
|
Page<AttDamProfile> data = service.page(page.getPageSo().toPage(), query);
|
|
|
|
|
data.getRecords().forEach(o -> o.setFiles(
|
|
|
|
|
fileService.getFiles(getGroupId(),o.getProfileCode())
|
|
|
|
|
));
|
|
|
|
|
return R.ok(data);
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-10 13:16:22 +08:00
|
|
|
|
2024-07-17 17:38:06 +08:00
|
|
|
@Override
|
|
|
|
|
public String getGroupId() {
|
|
|
|
|
return "AttDamProfile";
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|