Merge remote-tracking branch 'origin/master'

master
Coolkid 2024-01-26 17:23:54 +08:00
commit 43bd74d842
12 changed files with 568 additions and 287 deletions

View File

@ -18,6 +18,8 @@
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<alibaba.easyexcel.version>3.3.2</alibaba.easyexcel.version>
</properties> </properties>
<dependencies> <dependencies>
@ -33,7 +35,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.3.2</version> <version>${alibaba.easyexcel.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -3,16 +3,23 @@ package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.dto.StDamDto; import com.gunshi.project.xyt.entity.dto.StDamDto;
import com.gunshi.project.xyt.entity.dto.StEqptDto;
import com.gunshi.project.xyt.entity.dto.StResDto; import com.gunshi.project.xyt.entity.dto.StResDto;
import com.gunshi.project.xyt.entity.dto.StRvDto; import com.gunshi.project.xyt.entity.dto.StRvDto;
import com.gunshi.project.xyt.entity.vo.StResVo; import com.gunshi.project.xyt.entity.vo.StResVo;
import com.gunshi.project.xyt.model.StDamB; import com.gunshi.project.xyt.model.StDamB;
import com.gunshi.project.xyt.model.StEqptB;
import com.gunshi.project.xyt.model.StResB; import com.gunshi.project.xyt.model.StResB;
import com.gunshi.project.xyt.model.StRvB; import com.gunshi.project.xyt.model.StRvB;
import com.gunshi.project.xyt.service.EngineeringDrainageService; import com.gunshi.project.xyt.service.EngineeringDrainageService;
import com.gunshi.project.xyt.so.StDamPageSo;
import com.gunshi.project.xyt.so.StEqptPageSo;
import com.gunshi.project.xyt.so.StResPageSo;
import com.gunshi.project.xyt.so.StRvPageSo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.models.security.SecurityScheme;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -57,34 +64,10 @@ public class EngineeringDrainageController {
return R.ok(); return R.ok();
} }
@Operation(summary = "查询水库的基础信息") @Operation(summary = "分页查询水库的基础信息")
@GetMapping("/queryStRes") @PostMapping("/queryStRes")
public R<List<StResVo>> queryStRes(){ public R<Page<StResB>> pageStRes(@RequestBody @Validated StResPageSo stResPageSo){
return R.ok(engineeringDrainageService.queryStRes()); return R.ok(engineeringDrainageService.pageStRes(stResPageSo));
}
@Operation(summary = "根据水库代码查询水库的基础信息")
@GetMapping("/queryByResCode")
public R<StResB> queryByResCode(@Parameter(description = "水库代码") @RequestParam("resCode") String resCode){
return R.ok(engineeringDrainageService.queryByResCode(resCode));
}
@Operation(summary = "根据水库ID查询水库的基础信息")
@GetMapping("/queryByResId")
public R<StResVo> queryByResId(@Parameter(description = "水库ID") @RequestParam("resId") String resId){
return R.ok(engineeringDrainageService.queryByResId(resId));
}
@Operation(summary = "根据水库名称模糊查询水库的基础信息")
@GetMapping("/queryLikeResName")
public R<List<StResVo>> queryLikeResName(@Parameter(description = "水库名称") @RequestParam("resName") String resName){
return R.ok(engineeringDrainageService.queryLikeResName(resName));
}
@Operation(summary = "根据水库规模查询水库的基础信息")
@GetMapping("/queryByEngScal")
public R<List<StResVo>> queryByEngScal(@Parameter(description = "水库规模") @RequestParam("engScal") String engScal){
return R.ok(engineeringDrainageService.queryByEngScal(engScal));
} }
@Operation(summary = "新增河流基础信息") @Operation(summary = "新增河流基础信息")
@ -108,33 +91,10 @@ public class EngineeringDrainageController {
return R.ok(); return R.ok();
} }
@Operation(summary = "根据河流代码查询河流的基础信息")
@GetMapping("/queryByRvCode")
public R<StRvB> queryByRvCode(@Parameter(description = "河流代码") @RequestParam("rvCode") String rvCode){
return R.ok(engineeringDrainageService.queryByRvCode(rvCode));
}
@Operation(summary = "根据河流ID查询河流的基础信息")
@GetMapping("/queryByRvId")
public R<StRvB> queryByRvId(@Parameter(description = "河流ID") @RequestParam("rvId") String rvId){
return R.ok(engineeringDrainageService.queryByRvId(rvId));
}
@Operation(summary = "分页查询河流的基础信息") @Operation(summary = "分页查询河流的基础信息")
@GetMapping("/pageStRv") @PostMapping("/queryByRvCode")
public R<Page<StRvB>> pageStRv( public R<Page<StRvB>> pageStRv(@RequestBody @Validated StRvPageSo stRvPageSo){
@Parameter(description = "当前页") @RequestParam("pageNum") Integer pageNum, return R.ok(engineeringDrainageService.pageStRv(stRvPageSo));
@Parameter(description = "每页显示的条数") @RequestParam("pageSize")Integer pageSize){
return R.ok(engineeringDrainageService.pageStRv(pageNum,pageSize));
}
@Operation(summary = "根据河流名称模糊查询河流信息")
@GetMapping("/queryLikeRvName")
public R<Page<StRvB>> queryLikeRvName(
@Parameter(description = "河流名称") @RequestParam("rvName")String rvName,
@Parameter(description = "当前页") @RequestParam("pageNum") Integer pageNum,
@Parameter(description = "每页显示的条数") @RequestParam("pageSize")Integer pageSize){
return R.ok(engineeringDrainageService.queryLikeRvName(rvName, pageNum, pageSize));
} }
@Operation(summary = "新增大坝基础信息") @Operation(summary = "新增大坝基础信息")
@ -151,41 +111,44 @@ public class EngineeringDrainageController {
return R.ok(); return R.ok();
} }
@Operation(summary = "删除大坝基础信息") @Operation(summary = "根据大坝ID删除大坝基础信息")
@GetMapping("/deleteStDam") @GetMapping("/deleteStDam")
public R<String> deleteStDam(@Parameter(description = "大坝ID") @RequestParam("damId") String damId){ public R<String> deleteStDam(@Parameter(description = "大坝ID") @RequestParam("damId") String damId){
engineeringDrainageService.deleteStDam(damId); engineeringDrainageService.deleteStDam(damId);
return R.ok(); return R.ok();
} }
@Operation(summary = "根据大坝ID查询大坝信息") @Operation(summary = "分页查询大坝信息")
@GetMapping("/queryByDamId") @PostMapping("/queryByDamId")
public R<StDamB> queryByDamId(@Parameter(description = "大坝ID") @RequestParam("damId") String damId){ public R<Page<StDamB>> queryByDamId(@RequestBody @Validated StDamPageSo stDamPageSo){
return R.ok(engineeringDrainageService.queryByDamId(damId)); return R.ok(engineeringDrainageService.pageStDam(stDamPageSo));
} }
@Operation(summary = "根据大坝代码查询大坝信息") @Operation(summary = "新增量水堰基础信息")
@GetMapping("/queryByDamCode") @PostMapping("/insertStEqpt")
public R<StDamB> queryByDamCode(@Parameter(description = "大坝代码") @RequestParam("damCode") String damCode){ public R<String> insertStEqpt(@RequestBody @Validated StEqptDto stEqptDto){
return R.ok(engineeringDrainageService.queryByDamCode(damCode)); engineeringDrainageService.insertStEqpt(stEqptDto);
return R.ok();
} }
@Operation(summary = "分页查询大坝基础信息") @Operation(summary = "更新量水堰基础信息")
@GetMapping("/pageStDam") @PostMapping("/updateStEqpt")
public R<Page<StDamB>> pageStDam( public R<String> updateStEqpt(@RequestBody StEqptB stEqptB){
@Parameter(description = "当前页") @RequestParam("pageNum") Integer pageNum, engineeringDrainageService.updateStEqpt(stEqptB);
@Parameter(description = "每页显示的条数") @RequestParam("pageSize")Integer pageSize){ return R.ok();
return R.ok(engineeringDrainageService.pageStDam(pageNum,pageSize));
} }
@Operation(summary = "根据大坝名称模糊查询大坝基础信息") @Operation(summary = "根据量水设施ID删除量水堰基础信息")
@GetMapping("/queryLikeDamName") @GetMapping("/deleteStEqpt")
public R<Page<StDamB>> queryLikeDamName( public R<String> deleteStEqpt(@Parameter(description = "量水设施ID") @RequestParam("wmeqId") String wmeqId){
@Parameter(description = "大坝名称") @RequestParam("damName")String damName, engineeringDrainageService.deleteStEqpt(wmeqId);
@Parameter(description = "当前页") @RequestParam("pageNum") Integer pageNum, return R.ok();
@Parameter(description = "每页显示的条数") @RequestParam("pageSize")Integer pageSize){
return R.ok(engineeringDrainageService.queryLikeDamName(damName,pageNum,pageSize));
} }
@Operation(summary = "根据量水设施ID查询量水堰基础信息")
@GetMapping("/queryByWmegId")
public R<Page<StEqptB>> pageEqpt(@RequestBody @Validated StEqptPageSo stEqptPageSo){
return R.ok(engineeringDrainageService.pageStEqpt(stEqptPageSo));
}
} }

View File

@ -62,7 +62,7 @@ public class WaterQualityController {
@Operation(summary = "水质监测数据分页查询") @Operation(summary = "水质监测数据分页查询")
@PostMapping("/page") @PostMapping("/page")
public R<Page<StWaterQualityR>> page( public R<Page<StWaterQualityR>> page(
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody(required = true) @Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody
WaterQualityPageSo waterQualityPageSo WaterQualityPageSo waterQualityPageSo
) { ) {
return R.ok(waterqualityService.page(waterQualityPageSo)); return R.ok(waterqualityService.page(waterQualityPageSo));
@ -71,16 +71,16 @@ public class WaterQualityController {
@Operation(summary = "水质监测数据导出") @Operation(summary = "水质监测数据导出")
@PostMapping("/export") @PostMapping("/export")
public void export( public void export(
@Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody(required = true) @Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody
WaterQualityPageSo waterQualityPageSo, HttpServletResponse response) { WaterQualityPageSo waterQualityPageSo, HttpServletResponse response) {
waterqualityService.export(waterQualityPageSo, response); waterqualityService.export(waterQualityPageSo, response);
} }
@Operation(summary = "水质监测数据导入") @Operation(summary = "水质监测数据导入")
@PostMapping("/import") @PostMapping("/import")
public R<String> importExcel(@RequestParam("file") MultipartFile file) { public R<Boolean> importExcel(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) { if (file.isEmpty()) {
return R.error(400, "请选择上传文件"); return R.error(400, "请选择上传文件",false);
} }
try { try {
@ -89,7 +89,7 @@ public class WaterQualityController {
} catch (IOException e) { } catch (IOException e) {
return R.error(500, "文件上传失败: " + e.getMessage()); return R.error(500, "文件上传失败: " + e.getMessage(),false);
} }
} }

View File

@ -0,0 +1,56 @@
package com.gunshi.project.xyt.entity.dto;
import com.gunshi.project.xyt.model.StEqptB;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* TODO
*
* @ClassName StEqptDto
* @Author Huang Qianxiang
* @Date 2024/1/26 9:47
*/
@EqualsAndHashCode(callSuper = true)
@Schema(description="量水堰基础信息DTO")
@Data
public class StEqptDto extends StEqptB {
/**
*
*/
@Schema(description="量水设施代码")
@NotNull(message = "量水设施代码不能为空")
private String wmeqCode;
/**
*
*/
@Schema(description="量水设施名称")
@NotNull(message = "量水设施名称不能为空")
private String wmeqName;
/**
*
*/
@Schema(description="所属行政区划代码")
@NotNull(message = "所属行政区划代码不能为空")
private String addvcd;
/**
*
*/
@Schema(description="经度")
@NotNull(message = "经度不能为空")
private BigDecimal lgtd;
/**
*
*/
@Schema(description="纬度")
@NotNull(message = "维度不能为空")
private BigDecimal lttd;
}

View File

@ -0,0 +1,41 @@
package com.gunshi.project.xyt.entity.dto;
import com.gunshi.project.xyt.model.StGateB;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* TODO
*
* @ClassName StGateDto
* @Author Huang Qianxiang
* @Date 2024/1/26 9:35
*/
@EqualsAndHashCode(callSuper = true)
@Schema(description="闸阀基础信息DTO")
@Data
public class StGateDto extends StGateB {
/**
*
*/
@Schema(description="闸阀编码")
@NotNull(message = "闸阀编码不能为空")
private String gateCd;
/**
*
*/
@Schema(description="闸阀名称")
@NotNull(message = "闸阀名称不能为空")
private String gateNm;
/**
*
*/
@Schema(description="所在位置")
@NotNull(message = "所在位置不能为空")
private String gtlc;
}

View File

@ -1,24 +1,31 @@
package com.gunshi.project.xyt.service; package com.gunshi.project.xyt.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.xyt.entity.dto.StDamDto; import com.gunshi.project.xyt.entity.dto.*;
import com.gunshi.project.xyt.entity.dto.StResDto;
import com.gunshi.project.xyt.entity.dto.StRvDto;
import com.gunshi.project.xyt.entity.vo.StResVo; import com.gunshi.project.xyt.entity.vo.StResVo;
import com.gunshi.project.xyt.model.*; import com.gunshi.project.xyt.model.*;
import com.gunshi.project.xyt.model.StDamBAutoDao; import com.gunshi.project.xyt.model.StDamBAutoDao;
import com.gunshi.project.xyt.model.StEqptBAutoDao;
import com.gunshi.project.xyt.model.StGateBAutoDao;
import com.gunshi.project.xyt.model.StResBAutoDao; import com.gunshi.project.xyt.model.StResBAutoDao;
import com.gunshi.project.xyt.model.StResStcdRefAutoDao; import com.gunshi.project.xyt.model.StResStcdRefAutoDao;
import com.gunshi.project.xyt.model.StRvBAutoDao; import com.gunshi.project.xyt.model.StRvBAutoDao;
import com.gunshi.project.xyt.so.StDamPageSo;
import com.gunshi.project.xyt.so.StEqptPageSo;
import com.gunshi.project.xyt.so.StResPageSo;
import com.gunshi.project.xyt.so.StRvPageSo;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.print.DocFlavor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -43,6 +50,12 @@ public class EngineeringDrainageService {
private StRvBAutoDao stRvBAutoDao; private StRvBAutoDao stRvBAutoDao;
@Resource @Resource
private StDamBAutoDao stDamBAutoDao; private StDamBAutoDao stDamBAutoDao;
@Resource
private StGateBAutoDao stGateBAutoDao;
@Resource
private StEqptBAutoDao stEqptBAutoDao;
/** /**
* *
@ -64,14 +77,6 @@ public class EngineeringDrainageService {
//保存水库基本信息 //保存水库基本信息
stResBAutoDao.save(stResB); stResBAutoDao.save(stResB);
StResStcdRef stResStcdRef = new StResStcdRef();
stResStcdRef.setResId(resId);
stResStcdRef.setStcd(stResDto.getSTCD());
stResStcdRef.setTm(date);
//保存测站关系
stResStcdRefAutoDao.save(stResStcdRef);
} }
/** /**
@ -95,21 +100,6 @@ public class EngineeringDrainageService {
stResB.setTm(date); stResB.setTm(date);
//更新水库基本信息 //更新水库基本信息
stResBAutoDao.updateById(stResB); stResBAutoDao.updateById(stResB);
if (stResDto.getSTCD() != null){
StResStcdRef stResStcdRef = new StResStcdRef();
stResStcdRef.setResId(resId);
stResStcdRef.setStcd(stResDto.getSTCD());
stResStcdRef.setTm(date);
//更新水库测站关系
StResStcdRef byId1 = stResStcdRefAutoDao.getById(resId);
if (byId1 != null) {
//先删除之前存在的关系
stResStcdRefAutoDao.removeById(resId);
}
//更新当前水库测站关系
stResStcdRefAutoDao.save(stResStcdRef);
}
} }
/** /**
@ -129,8 +119,38 @@ public class EngineeringDrainageService {
updateWrapper.eq(StResB.COL_RES_ID,resId) updateWrapper.eq(StResB.COL_RES_ID,resId)
.set(StResB.COL_STATUS,0); .set(StResB.COL_STATUS,0);
stResBAutoDao.update(updateWrapper); stResBAutoDao.update(updateWrapper);
//删除水库测站关系 }
stResStcdRefAutoDao.removeById(resId);
/**
*
* @param stResPageSo
* @return
*/
public Page<StResB> pageStRes(StResPageSo stResPageSo){
if (StringUtils.isNotEmpty(stResPageSo.getResId())){
StResB stResB = stResBAutoDao.getById(stResPageSo.getResId());
if (stResB == null){
return null;
}
List<StResB> resBList = List.of(stResB);
return new Page<StResB>(1,1,1).setRecords(resBList);
}
LambdaQueryWrapper<StResB> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(stResPageSo.getResName())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stResPageSo.getResName()),StResB::getResName,stResPageSo.getResName());
}
if (StringUtils.isNotEmpty(stResPageSo.getResCode())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stResPageSo.getResCode()),StResB::getResCode,stResPageSo.getResCode());
}
if (StringUtils.isNotEmpty(stResPageSo.getEngScal())){
lambdaQueryWrapper.eq(StringUtils.isNotEmpty(stResPageSo.getEngScal()),StResB::getEngScal,stResPageSo.getEngScal());
}
if (stResPageSo.getStatus() != null){
lambdaQueryWrapper.eq(StResB::getStatus,stResPageSo.getStatus());
}
return stResBAutoDao.page(stResPageSo.getPageSo().toPage(),lambdaQueryWrapper);
} }
/** /**
@ -144,83 +164,6 @@ public class EngineeringDrainageService {
return stResBAutoDao.getOne(queryWrapper); return stResBAutoDao.getOne(queryWrapper);
} }
/**
* ID
* @param resId ID
* @return
*/
public StResVo queryByResId(String resId) {
StResB stResB = stResBAutoDao.getById(resId);
StResStcdRef stResStcdRef = stResStcdRefAutoDao.getById(resId);
if (stResB == null) {
throw new IllegalArgumentException("resId:" + resId + "不存在");
}
StResVo stResVo = new StResVo();
BeanUtil.copyProperties(stResB,stResVo);
stResVo.setSTCD(stResStcdRef.getStcd());
return stResVo;
}
/**
*
* @return
*/
public List<StResVo> queryStRes() {
List<StResB> stResBList = stResBAutoDao
.list(new QueryWrapper<StResB>().eq(StResB.COL_STATUS,1));
List<StResVo> stResVoList = new ArrayList<>();
stResBList.stream().forEach(stResB -> {
StResVo stResVo = new StResVo();
BeanUtil.copyProperties(stResB,stResVo);
StResStcdRef stResStcdRef = stResStcdRefAutoDao.getById(stResB.getResId());
stResVo.setSTCD(stResStcdRef.getStcd());
stResVoList.add(stResVo);
});
return stResVoList;
}
/**
*
* @param resName
* @return
*/
public List<StResVo> queryLikeResName(String resName) {
QueryWrapper<StResB> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StResB.COL_RES_NAME,resName)
.eq(StResB.COL_STATUS,1);
List<StResB> stResBList = stResBAutoDao.list(queryWrapper);
List<StResVo> stResVoList = new ArrayList<>();
stResBList.stream().forEach(stResB -> {
StResVo stResVo = new StResVo();
BeanUtil.copyProperties(stResB,stResVo);
StResStcdRef stResStcdRef = stResStcdRefAutoDao.getById(stResB.getResId());
stResVo.setSTCD(stResStcdRef.getStcd());
stResVoList.add(stResVo);
});
return stResVoList;
}
/**
*
* @param engScal
* @return
*/
public List<StResVo> queryByEngScal(String engScal) {
QueryWrapper<StResB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StResB.COL_ENG_SCAL,engScal)
.eq(StResB.COL_STATUS,1);
List<StResB> stResBList = stResBAutoDao.list(queryWrapper);
List<StResVo> stResVoList = new ArrayList<>();
stResBList.stream().forEach(stResB -> {
StResVo stResVo = new StResVo();
BeanUtil.copyProperties(stResB,stResVo);
StResStcdRef stResStcdRef = stResStcdRefAutoDao.getById(stResB.getResId());
stResVo.setSTCD(stResStcdRef.getStcd());
stResVoList.add(stResVo);
});
return stResVoList;
}
/** /**
* *
* @param stRvDto DTO * @param stRvDto DTO
@ -270,6 +213,33 @@ public class EngineeringDrainageService {
stRvBAutoDao.update(updateWrapper); stRvBAutoDao.update(updateWrapper);
} }
/**
*
* @param stRvPageSo
*/
public Page<StRvB> pageStRv(StRvPageSo stRvPageSo){
if (StringUtils.isNotEmpty(stRvPageSo.getRvId())){
StRvB stRvB = stRvBAutoDao.getById(stRvPageSo.getRvId());
if (stRvB == null){
return null;
}
List<StRvB> rvBList = List.of(stRvB);
return new Page<StRvB>(1,1,1).setRecords(rvBList);
}
LambdaQueryWrapper<StRvB> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(stRvPageSo.getRvName())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stRvPageSo.getRvName()),StRvB::getRvCode,stRvPageSo.getRvName());
}
if (StringUtils.isNotEmpty(stRvPageSo.getRvCode())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stRvPageSo.getRvCode()),StRvB::getRvCode,stRvPageSo.getRvCode());
}
if (stRvPageSo.getStatus() != null){
lambdaQueryWrapper.eq(StRvB::getStatus,stRvPageSo.getStatus());
}
return stRvBAutoDao.page(stRvPageSo.getPageSo().toPage(),lambdaQueryWrapper);
}
/** /**
* *
* @param rvCode * @param rvCode
@ -282,44 +252,6 @@ public class EngineeringDrainageService {
return stRvBAutoDao.getOne(queryWrapper); return stRvBAutoDao.getOne(queryWrapper);
} }
/**
* ID
* @param rvId ID
* @return
*/
public StRvB queryByRvId(String rvId) {
StRvB stRvB = stRvBAutoDao.getById(rvId);
if (stRvB == null){
throw new IllegalArgumentException("河流ID: "+ rvId +"不存在");
}
return stRvB;
}
/**
*
* @param pageNum
* @param pageSize
* @return
*/
public Page<StRvB> pageStRv(int pageNum,int pageSize) {
QueryWrapper<StRvB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StRvB.COL_STATUS,1);
return stRvBAutoDao.page(new Page<>(pageNum,pageSize),queryWrapper);
}
/**
*
* @param rvName
* @param pageNum
* @param pageSize
* @return
*/
public Page<StRvB> queryLikeRvName(String rvName,int pageNum,int pageSize) {
QueryWrapper<StRvB> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StRvB.COL_RV_NAME,rvName)
.eq(StRvB.COL_STATUS,1);
return stRvBAutoDao.page(new Page<>(pageNum,pageSize),queryWrapper);
}
/** /**
* *
@ -353,7 +285,7 @@ public class EngineeringDrainageService {
} }
/** /**
* * ID
* @param damId ID * @param damId ID
*/ */
public void deleteStDam(String damId) { public void deleteStDam(String damId) {
@ -368,16 +300,31 @@ public class EngineeringDrainageService {
} }
/** /**
* ID *
* @param damId ID * @param stDamPageSo
* @return * @return
*/ */
public StDamB queryByDamId(String damId) { public Page<StDamB> pageStDam(StDamPageSo stDamPageSo){
StDamB stDamB = stDamBAutoDao.getById(damId); if (StringUtils.isNotEmpty(stDamPageSo.getDamId())){
if (stDamB == null){ StDamB stDamB = stDamBAutoDao.getById(stDamPageSo.getDamId());
throw new IllegalArgumentException("大坝ID: " + damId+ "不存在"); if (stDamB == null){
return null;
}
List<StDamB> damBList = List.of(stDamB);
return new Page<StDamB>(1,1,1).setRecords(damBList);
} }
return stDamB; LambdaQueryWrapper<StDamB> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(stDamPageSo.getDamName())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stDamPageSo.getDamName()),StDamB::getDamName,stDamPageSo.getDamName());
}
if (StringUtils.isNotEmpty(stDamPageSo.getDamCode())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stDamPageSo.getDamCode()),StDamB::getDamCode,stDamPageSo.getDamCode());
}
if (stDamPageSo.getStatus() != null){
lambdaQueryWrapper.eq(StDamB::getStatus,stDamPageSo.getStatus());
}
return stDamBAutoDao.page(stDamPageSo.getPageSo().toPage(),lambdaQueryWrapper);
} }
/** /**
@ -393,28 +340,125 @@ public class EngineeringDrainageService {
} }
/** /**
* *
* @param pageNum * @param stGateDto DTO
* @param pageSize
* @return
*/ */
public Page<StDamB> pageStDam(int pageNum, int pageSize) { public void insertStGate(StGateDto stGateDto){
QueryWrapper<StDamB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StDamB.COL_STATUS,1);
return stDamBAutoDao.page(new Page<>(pageNum,pageSize),queryWrapper);
} }
/** /**
* *
* @param damName * @param stGateB
* @param pageNum */
* @param pageSize public void updateStGate(StGateB stGateB){
}
/**
* ID
* @param gateId ID
*/
public void deleteStGate(String gateId){
QueryWrapper<StGateB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StGateB.COL_GATE_ID,gateId)
.eq(StGateB.COL_STATUS,1);
StGateB stGateB = stGateBAutoDao.getById(gateId);
if (stGateB == null){
throw new IllegalArgumentException("闸阀ID : " + gateId + "不存在或闸阀ID : " + gateId + "已被禁用");
}
UpdateWrapper<StGateB> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq(StGateB.COL_GATE_ID,gateId)
.set(StGateB.COL_STATUS,0);
stGateBAutoDao.update(updateWrapper);
}
/**
*
* @param stEqptDto DTO
*/
public void insertStEqpt(StEqptDto stEqptDto){
if (queryByWmegCode(stEqptDto.getWmeqCode()) != null){
throw new IllegalArgumentException("量水设施代码不能为空");
}
StEqptB stEqptB = new StEqptB();
BeanUtil.copyProperties(stEqptDto,stEqptB);
long id = IdWorker.getId();
stEqptB.setWmeqId(id);
stEqptB.setStatus(1);
stEqptBAutoDao.save(stEqptB);
}
/**
*
* @param stEqptB
*/
public void updateStEqpt(StEqptB stEqptB){
Long wmeqId = stEqptB.getWmeqId();
StEqptB stEqptB1 = stEqptBAutoDao.getById(wmeqId);
if (stEqptB1 == null){
throw new IllegalArgumentException("量水设施ID: " + wmeqId + "不存在");
}
stEqptBAutoDao.updateById(stEqptB);
}
/**
* ID
* @param wmeqId ID
*/
public void deleteStEqpt(String wmeqId){
QueryWrapper<StEqptB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StEqptB.COL_WMEQ_ID,wmeqId)
.eq(StEqptB.COL_STATUS,1);
StEqptB stEqptB1 = stEqptBAutoDao.getOne(queryWrapper);
if (stEqptB1 == null){
throw new IllegalArgumentException("量水设施ID: " + wmeqId + "不存在或量水设施ID: " + wmeqId + "被禁用");
}
UpdateWrapper<StEqptB> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq(StEqptB.COL_WMEQ_ID,wmeqId)
.set(StEqptB.COL_STATUS,0);
stEqptBAutoDao.update(updateWrapper);
}
/**
*
* @param stEqptPageSo
* @return * @return
*/ */
public Page<StDamB> queryLikeDamName(String damName, int pageNum, int pageSize) { public Page<StEqptB> pageStEqpt(StEqptPageSo stEqptPageSo){
QueryWrapper<StDamB> queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(stEqptPageSo.getWmeqId())){
queryWrapper.like(StDamB.COL_DAM_NAME,damName) StEqptB stEqptB = stEqptBAutoDao.getById(stEqptPageSo.getWmeqId());
.eq(StDamB.COL_STATUS,1); if (stEqptB == null){
return stDamBAutoDao.page(new Page<>(pageNum,pageSize),queryWrapper); return null;
}
List<StEqptB> eqptBList = List.of(stEqptB);
return new Page<StEqptB>(1,1,1).setRecords(eqptBList);
}
LambdaQueryWrapper<StEqptB> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(stEqptPageSo.getWmeqName())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stEqptPageSo.getWmeqName()),StEqptB::getWmeqName,stEqptPageSo.getWmeqName());
}
if (StringUtils.isNotEmpty(stEqptPageSo.getWmeqCode())){
lambdaQueryWrapper.like(StringUtils.isNotEmpty(stEqptPageSo.getWmeqCode()),StEqptB::getWmeqCode,stEqptPageSo.getWmeqCode());
}
if (stEqptPageSo.getStatus() != null){
lambdaQueryWrapper.eq(StEqptB::getStatus,stEqptPageSo.getStatus());
}
return stEqptBAutoDao.page(stEqptPageSo.getPageSo().toPage(),lambdaQueryWrapper);
} }
/**
*
* @param wmeqCode
* @return
*/
public StEqptB queryByWmegCode(String wmeqCode){
QueryWrapper<StEqptB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StEqptB.COL_WMEQ_CODE,wmeqCode)
.eq(StEqptB.COL_STATUS,1);
StEqptB stEqptB = stEqptBAutoDao.getOne(queryWrapper);
return stEqptB;
}
} }

View File

@ -22,13 +22,13 @@ public interface WaterQualityService {
void export(WaterQualityPageSo waterQualityPageSo, HttpServletResponse response); void export(WaterQualityPageSo waterQualityPageSo, HttpServletResponse response);
String importExcel(MultipartFile file) throws IOException; Boolean importExcel(MultipartFile file) throws IOException;
String add(StWaterQualityR stWaterQualityR); Boolean add(StWaterQualityR stWaterQualityR);
String addList(List<StWaterQualityR> stWaterQualityRList); Boolean addList(List<StWaterQualityR> stWaterQualityRList);
String update(StWaterQualityR StWaterQualityR); // String update(StWaterQualityR StWaterQualityR);
String delete(String id); // String delete(String id);
} }

View File

@ -28,8 +28,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static java.util.Objects.requireNonNull;
/** /**
* Description: * Description:
* Created by xusan on 2023/1/23. * Created by xusan on 2023/1/23.
@ -67,6 +65,7 @@ public class WaterQualityServiceImpl extends BaseOrderDao<WaterQualityMapper, St
return super.page(pageQueryCriteria.getPageSo().toPage(), query); return super.page(pageQueryCriteria.getPageSo().toPage(), query);
} }
/** /**
@ -121,18 +120,15 @@ public class WaterQualityServiceImpl extends BaseOrderDao<WaterQualityMapper, St
} }
@Override @Override
public String importExcel(MultipartFile file) throws IOException { public Boolean importExcel(MultipartFile file) throws IOException {
// 创建一个用于存储数据的List // 创建一个用于存储数据的List
List<StWaterQualityR> data = new ArrayList<>(); List<StWaterQualityR> data = new ArrayList<>();
EasyExcel.read(file.getInputStream(), StWaterQualityR.class, new PageReadListener<StWaterQualityR>(data::addAll)).sheet().doRead(); EasyExcel.read(file.getInputStream(), StWaterQualityR.class, new PageReadListener<StWaterQualityR>(data::addAll)).sheet().doRead();
for (StWaterQualityR o : data) {
o.setId(null);
}
return this.addList(data); return this.addList(data);
} }
@ -142,41 +138,60 @@ public class WaterQualityServiceImpl extends BaseOrderDao<WaterQualityMapper, St
* @param o * @param o
*/ */
@Override @Override
public String add(StWaterQualityR o) { public Boolean add(StWaterQualityR o) {
return this.save(o) ? "成功":"失败"; // 排除id
o.setId(null);
// 判断 站码和时间是否重复
final LambdaQueryWrapper<StWaterQualityR> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(StWaterQualityR::getStcd,o.getStcd())
.eq(StWaterQualityR::getSpt,o.getSpt());
if (this.count(queryWrapper) > 0) {
log.info("站码和采样时间重复 {}", String.format("%s", o));
throw new IllegalArgumentException("站码和采样时间必须唯一");
}
return this.save(o);
} }
@Override @Override
public String addList(List<StWaterQualityR> stWaterQualityRList) { public Boolean addList(List<StWaterQualityR> stWaterQualityRList) {
try { try {
for (StWaterQualityR o : stWaterQualityRList) { for (StWaterQualityR o : stWaterQualityRList) {
this.add(o); this.add(o);
} }
}catch (Exception e) { }catch (Exception e) {
return "失败"; return false;
} }
return "成功"; return true;
// return this.saveBatch(stWaterQualityRList) ? "成功":"失败"; // return this.saveBatch(stWaterQualityRList) ? "成功":"失败";
} }
/** // /**
* // * 修改水质
* // *
* @param o // * @param o 水质
*/ // */
@Override // @Override
public String update(StWaterQualityR o) { // public String update(StWaterQualityR o) {
return this.updateById(o) ? "成功":"失败"; // return this.updateById(o) ? "成功":"失败";
} // }
//
/** // /**
* // * 删除水质
* // *
* @param id id // * @param id id
*/ // */
@Override // @Override
public String delete(String id) { // public String delete(String id) {
return this.removeById(id) ? "成功":"失败"; // return this.removeById(id) ? "成功":"失败";
} // }
} }

View File

@ -0,0 +1,39 @@
package com.gunshi.project.xyt.so;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* TODO
*
* @ClassName StDamPageSo
* @Author Huang Qianxiang
* @Date 2024/1/26 16:18
*/
@Data
@Schema(description = "大坝基本信息查询参数")
public class StDamPageSo {
@NotNull(message = "分页参数不能为空")
private PageSo pageSo;
@Schema(description="大坝ID")
private String damId;
@Schema(description="大坝代码")
private String damCode;
@Schema(description="大坝名称")
private String damName;
@Schema(description="状态 1启用 0禁用")
private Integer status;
}

View File

@ -0,0 +1,37 @@
package com.gunshi.project.xyt.so;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* TODO
*
* @ClassName StEqptPageSo
* @Author Huang Qianxiang
* @Date 2024/1/26 16:28
*/
@Data
@Schema(description = "量水堰基本信息查询参数")
public class StEqptPageSo {
@NotNull(message = "分页参数不能为空")
private PageSo pageSo;
@Schema(description="量水设施ID")
private String wmeqId;
@Schema(description="量水设施代码")
private String wmeqCode;
@Schema(description="量水设施名称")
private String wmeqName;
@Schema(description="状态 1:启用 0:禁用")
private Integer status;
}

View File

@ -0,0 +1,42 @@
package com.gunshi.project.xyt.so;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* TODO
*
* @ClassName StResPageSo
* @Author Huang Qianxiang
* @Date 2024/1/26 15:38
*/
@Data
@Schema(description = "水库基本信息查询参数")
public class StResPageSo {
@NotNull(message = "分页参数不能为空")
private PageSo pageSo;
@Schema(description="水库id")
private String resId;
@Schema(description="水库代码")
private String resCode;
@Schema(description="水库名称")
private String resName;
@Schema(description="水库规模 dict_id")
private String engScal;
@Schema(description=" 状态 1启用 0禁用,默认1")
private Integer status;
}

View File

@ -0,0 +1,42 @@
package com.gunshi.project.xyt.so;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* TODO
*
* @ClassName StRvPageSo
* @Author Huang Qianxiang
* @Date 2024/1/26 16:03
*/
@Data
@Schema(description = "河流基本信息查询参数")
public class StRvPageSo {
@NotNull(message = "分页参数不能为空")
private PageSo pageSo;
@Schema(description="河流ID")
private String rvId;
@Schema(description="河流代码")
private String rvCode;
@Schema(description="河流名称")
private String rvName;
@TableField(value = "[STATUS]")
@Schema(description="状态 1启用 0禁用")
private Integer status;
}