Merge branch 'dev-tw'

This commit is contained in:
tangwei 2026-08-17 13:08:32 +08:00
commit 0164db2eb0
134 changed files with 6236 additions and 490 deletions

View File

@ -65,26 +65,28 @@ public class SecurityConfig {
.requestMatchers("/system/user/auditUser").permitAll()
.requestMatchers("/register/accessToken").permitAll()
.requestMatchers("/api/oauth2/oauth/token").permitAll()
.requestMatchers("/dict/cache/**").permitAll()
.requestMatchers("/sys/psbmodulelbb/**").permitAll()
.requestMatchers("/base/operationLog/**").permitAll()
// .requestMatchers("/dict/cache/**").permitAll()
// .requestMatchers("/sys/psbmodulelbb/**").permitAll()
// .requestMatchers("/base/operationLog/**").permitAll()
// .requestMatchers("/system/**").permitAll()
.requestMatchers("/qgcExport/**").permitAll()
// .requestMatchers("/eng/**").permitAll()
.requestMatchers("/eq/**").permitAll()
// .requestMatchers("/qgcExport/**").permitAll()
.requestMatchers("/eng/**").permitAll()
.requestMatchers("/system/**").permitAll()
// .requestMatchers("/eq/**").permitAll()
// .requestMatchers("/env/**").permitAll()
// .requestMatchers("/warn/**").permitAll()
// .requestMatchers("/threedroamb/**").permitAll()
// .requestMatchers("/overview/**").permitAll()
// .requestMatchers("/wt/**").permitAll()
// .requestMatchers("/fb/**").permitAll()
.requestMatchers("/wt/**").permitAll()
.requestMatchers("/system/acctPasswordPolicy/**").permitAll()
.requestMatchers("/fb/**").permitAll()
// .requestMatchers("/base/**").permitAll()
// .requestMatchers("/zq/**").permitAll()
// .requestMatchers("/wq/**").permitAll()
.requestMatchers("/wq/**").permitAll()
// .requestMatchers("/wte/**").permitAll()
// .requestMatchers("/vd/**").permitAll()
// .requestMatchers("/vap/**").permitAll()
// .requestMatchers("/fp/**").permitAll()
.requestMatchers("/vap/**").permitAll()
.requestMatchers("/fp/**").permitAll()
// .requestMatchers("/fpr/**").permitAll()
// .requestMatchers("/fh/**").permitAll()
// .requestMatchers("/data/**").permitAll()

View File

@ -29,7 +29,7 @@ public class WebConfig implements WebMvcConfigurer {
@Bean
public Cache<String, String> loginuserCache() {
return CacheUtil.newLRUCache(200);
return CacheUtil.newLRUCache(500);
}
public void putLoginCache(String key, String value, long timeoutSeconds) {

View File

@ -13,7 +13,7 @@ public class Constant {
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String CODE_KEY = "code-key-";
public static final long CODE_EXPIRATION_TIME = 1000 * 60 * 2;
public static final long CODE_EXPIRATION_TIME = 1000 * 60 * 5;
/**
* 用于IP定位转换
*/

View File

@ -36,5 +36,11 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
contextHolder.remove();
}
/**
* 根据数据源 key 获取目标数据源实例 dm-master / oracle-master
*/
public DataSource getDataSourceByKey(String key) {
Map<Object, DataSource> resolved = getResolvedDataSources();
return resolved == null ? null : resolved.get(key);
}
}

View File

@ -1,19 +1,29 @@
package com.yfd.platform.qgc_base.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.qgc_base.domain.SdEngInfoBHOperateRequest;
import com.yfd.platform.qgc_base.domain.SdFpssR;
import com.yfd.platform.qgc_base.service.ISdFpssRService;
import com.yfd.platform.qgc_data.service.AttachmentUploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 过鱼设施人工数据表 前端控制器
* </p>
*/
@Slf4j
@RestController
@RequestMapping("/data/fpssR")
@Tag(name = "过鱼数据管理")
@ -22,6 +32,12 @@ public class FpssRController {
@Resource
private ISdFpssRService fpssRService;
@Resource
private ObjectMapper objectMapper;
@Resource
private AttachmentUploadService attachmentUploadService;
@GetMapping("/page")
@Operation(summary = "分页查询过鱼数据列表")
public ResponseResult queryPageList(
@ -44,37 +60,170 @@ public class FpssRController {
@PostMapping("/add")
@Operation(summary = "新增过鱼数据")
public ResponseResult add(@RequestBody SdFpssR fpssR) {
boolean result = fpssRService.save(fpssR);
return result ? ResponseResult.success("新增成功") : ResponseResult.error("新增失败");
public ResponseResult add(@RequestParam("data") String dataStr,
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
@RequestParam(value = "vdFiles", required = false) List<MultipartFile> vdFiles) {
try {
SdEngInfoBHOperateRequest request = objectMapper.readValue(dataStr, SdEngInfoBHOperateRequest.class);
SdFpssR entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdFpssR.class);
if (entity == null) {
return ResponseResult.error("数据不能为空");
}
// 上传附件并设置到实体
applyUploadedFiles(entity, picFiles, vdFiles);
boolean result = fpssRService.add(entity, request.getSource());
return result ? ResponseResult.success("新增成功") : ResponseResult.error("新增失败");
} catch (Exception e) {
log.error("新增过鱼数据失败", e);
return ResponseResult.error("新增失败: " + e.getMessage());
}
}
@PostMapping("/update")
@Operation(summary = "修改过鱼数据")
public ResponseResult update(@RequestBody SdFpssR fpssR) {
boolean result = fpssRService.updateById(fpssR);
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
public ResponseResult update(@RequestParam("data") String dataStr,
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
@RequestParam(value = "vdFiles", required = false) List<MultipartFile> vdFiles) {
try {
SdEngInfoBHOperateRequest request = objectMapper.readValue(dataStr, SdEngInfoBHOperateRequest.class);
Map<String, Object> engInfo = request == null ? null : request.getEngInfo();
if (engInfo == null || engInfo.get("id") == null) {
return ResponseResult.error("数据或ID不能为空");
}
// 获取修改前的实体用于后续清理被替换的旧附件
SdFpssR before = fpssRService.getById((String) engInfo.get("id"));
List<String> oldAttachmentIds = before != null ? collectAttachmentIds(before) : Collections.emptyList();
// 上传新附件并合并回 patch map仅当本次有文件上传时才覆盖对应字段
SdFpssR tempEntity = objectMapper.convertValue(engInfo, SdFpssR.class);
applyUploadedFiles(tempEntity, picFiles, vdFiles);
if (picFiles != null && !picFiles.isEmpty()) {
engInfo.put("picpth", tempEntity.getPicpth());
}
if (vdFiles != null && !vdFiles.isEmpty()) {
engInfo.put("vdpth", tempEntity.getVdpth());
}
boolean result = fpssRService.update(engInfo, request.getSource());
if (result) {
// 清理被替换的旧附件
SdFpssR after = fpssRService.getById((String) engInfo.get("id"));
deleteReplacedFiles(oldAttachmentIds, collectAttachmentIds(after));
}
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
} catch (Exception e) {
log.error("修改过鱼数据失败", e);
return ResponseResult.error("修改失败: " + e.getMessage());
}
}
@PostMapping("/delete")
@Operation(summary = "删除过鱼数据")
public ResponseResult delete(@RequestParam String id) {
boolean result = fpssRService.removeById(id);
public ResponseResult delete(@RequestBody SdEngInfoBHOperateRequest request) {
List<String> ids = request == null ? null : request.getIds();
if (ids == null || ids.isEmpty()) {
return ResponseResult.error("ID不能为空");
}
// 删除前先收集所有需要清理的附件ID
List<String> allAttachmentIds = new ArrayList<>();
for (String id : ids) {
SdFpssR entity = fpssRService.getById(id);
if (entity != null) {
allAttachmentIds.addAll(collectAttachmentIds(entity));
}
}
boolean result = fpssRService.delete(ids, request.getSource());
if (result) {
// 删除关联的附件
deleteAttachments(allAttachmentIds);
}
return result ? ResponseResult.success("删除成功") : ResponseResult.error("删除失败");
}
@PostMapping("/batchDelete")
@Operation(summary = "批量删除过鱼数据")
public ResponseResult batchDelete(@RequestBody java.util.List<String> ids) {
if (ids == null || ids.isEmpty()) {
return ResponseResult.error("请选择要删除的数据");
}
boolean result = true;
for (String id : ids) {
if (!fpssRService.removeById(id)) {
result = false;
// ==================== 附件处理辅助方法 ====================
/**
* 上传图片/视频附件并追加附件ID到 picpth/vdpth 字段与已有ID以逗号拼接
*/
private void applyUploadedFiles(SdFpssR entity, List<MultipartFile> picFiles, List<MultipartFile> vdFiles) {
if (picFiles != null && !picFiles.isEmpty()) {
List<String> ids = attachmentUploadService.uploadMultipartFiles(picFiles);
if (!ids.isEmpty()) {
entity.setPicpth(mergeIds(entity.getPicpth(), ids));
}
}
if (vdFiles != null && !vdFiles.isEmpty()) {
List<String> ids = attachmentUploadService.uploadMultipartFiles(vdFiles);
if (!ids.isEmpty()) {
entity.setVdpth(mergeIds(entity.getVdpth(), ids));
}
}
return result ? ResponseResult.success("删除成功") : ResponseResult.error("部分删除失败");
}
}
/**
* 将新上传的附件ID列表追加到已有ID字符串后面逗号分隔
*/
private String mergeIds(String existing, List<String> ids) {
String newIds = ids.stream()
.filter(StrUtil::isNotBlank)
.collect(Collectors.joining(","));
if (StrUtil.isBlank(newIds)) {
return existing;
}
return StrUtil.isBlank(existing) ? newIds : existing + "," + newIds;
}
/**
* 收集实体中 picpth/vdpth 字段的附件ID
*/
private List<String> collectAttachmentIds(SdFpssR entity) {
List<String> ids = new ArrayList<>();
if (entity == null) {
return ids;
}
if (StrUtil.isNotBlank(entity.getPicpth())) {
Arrays.stream(entity.getPicpth().split(","))
.map(String::trim)
.filter(StrUtil::isNotBlank)
.forEach(ids::add);
}
if (StrUtil.isNotBlank(entity.getVdpth())) {
Arrays.stream(entity.getVdpth().split(","))
.map(String::trim)
.filter(StrUtil::isNotBlank)
.forEach(ids::add);
}
return ids;
}
/**
* 删除被替换的旧附件old中有但new中没有的
*/
private void deleteReplacedFiles(List<String> oldIds, List<String> newIds) {
for (String oldId : oldIds) {
if (StrUtil.isBlank(oldId)) {
continue;
}
if (!newIds.contains(oldId)) {
attachmentUploadService.deleteFile(oldId);
}
}
}
/**
* 批量删除附件
*/
private void deleteAttachments(List<String> attachmentIds) {
for (String id : attachmentIds) {
if (StrUtil.isNotBlank(id)) {
attachmentUploadService.deleteFile(id);
}
}
}
}

View File

@ -40,9 +40,8 @@ public class SdAiboxBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdAiboxBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdAiboxBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -44,10 +44,8 @@ public class SdAimonitorBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdAimonitorBH entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdAimonitorBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdArtsgBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdArtsgBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdArtsgBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdDwBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdDwBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdDwBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -1,8 +1,10 @@
package com.yfd.platform.qgc_base.controller;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdBVo;
import com.yfd.platform.qgc_base.domain.vo.RstcdTreeInfoVo;
import com.yfd.platform.qgc_base.service.ISdEngInfoBHService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -75,4 +77,18 @@ public class SdEngMonitorController {
public ResponseResult getQgcRvcdList(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(engInfoBHService.getQgcRvcdList(dataSourceRequest));
}
@PostMapping("/engTree/GetKendoList")
@Operation(summary = "树形结构数据信息 电站沿程排序")
public ResponseResult getEngTreeKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
DataSourceResult<RstcdTreeInfoVo> result = engInfoBHService.getEngTreeByAlong(dataSourceRequest);
return ResponseResult.successData(result);
}
@PostMapping("/vmsstbprpt/engTree/GetKendoList")
@Operation(summary = "沿程对象视图 树形结构数据信息 电站沿程排序")
public ResponseResult getVmsstbprptEngTreeKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
DataSourceResult<RstcdTreeInfoVo> result = engInfoBHService.getEngTreeByAlong(dataSourceRequest);
return ResponseResult.successData(result);
}
}

View File

@ -40,9 +40,8 @@ public class SdEqBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdEqBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdEqBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdFbrdBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdFbrdBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdFbrdBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdFhbtBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdFhbtBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdFhbtBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -20,10 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -88,9 +85,14 @@ public class SdFishDictoryBController {
if (entity == null) {
return ResponseResult.error("数据不能为空");
}
entity.setId(IdUtil.simpleUUID());
entity.setId(IdUtil.fastUUID());
entity.setCode(entity.getId());
// 名称重名校验
if (sdFishDictoryBService.existsByName(entity.getName())) {
return ResponseResult.error("该鱼类名称已存在");
}
// 上传文件并设置附件ID到实体
applyUploadedFiles(entity, files);
@ -109,23 +111,35 @@ public class SdFishDictoryBController {
@RequestParam(value = "files", required = false) List<MultipartFile> files) {
try {
SdEngInfoBHOperateRequest request = objectMapper.readValue(dataStr, SdEngInfoBHOperateRequest.class);
SdFishDictoryB entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdFishDictoryB.class);
if (entity == null || entity.getId() == null) {
Map<String, Object> engInfo = request == null ? null : request.getEngInfo();
if (engInfo == null || engInfo.get("id") == null) {
return ResponseResult.error("数据或ID不能为空");
}
// 名称重名校验仅当本次修改了名称时校验
Object newName = engInfo.get("name");
if (newName != null && StrUtil.isNotBlank(newName.toString())) {
String name = newName.toString();
if (sdFishDictoryBService.existsByNameExcludeId(name, (String) engInfo.get("id"))) {
return ResponseResult.error("该鱼类名称已存在");
}
}
// 获取修改前的实体用于后续清理旧文件
SdFishDictoryB before = sdFishDictoryBService.getById(entity.getId());
SdFishDictoryB before = sdFishDictoryBService.getById((String) engInfo.get("id"));
List<String> oldAttachmentIds = before != null ? collectAttachmentIds(before) : Collections.emptyList();
// 上传新文件并设置附件ID
applyUploadedFiles(entity, files);
SdFishDictoryB tempEntity = objectMapper.convertValue(engInfo, SdFishDictoryB.class);
applyUploadedFiles(tempEntity, files);
// 将文件处理后 inffile 合并回 patch map
engInfo.put("inffile", tempEntity.getInffile());
boolean result = sdFishDictoryBService.update(entity, request.getSource());
boolean result = sdFishDictoryBService.update(engInfo, request.getSource());
if (result) {
// 清理被替换的旧文件
deleteReplacedFiles(oldAttachmentIds, collectAttachmentIds(entity));
SdFishDictoryB after = sdFishDictoryBService.getById((String) engInfo.get("id"));
deleteReplacedFiles(oldAttachmentIds, collectAttachmentIds(after));
}
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
} catch (Exception e) {

View File

@ -89,9 +89,8 @@ public class SdFpssBHController {
@Log(module = "过鱼设施管理", value = "修改过鱼设施")
@PostMapping("/update")
@Operation(summary = "修改过鱼设施")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdFpssBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdFpssBH.class);
boolean result = sdFpssBHService.updateById(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = sdFpssBHService.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -18,9 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -64,27 +62,66 @@ public class SdFpssrlRController {
@Log(module = "过鱼设施自动数据管理", value = "新增过鱼自动数据")
@PostMapping("/add")
@Operation(summary = "新增过鱼自动数据")
public ResponseResult add(@RequestBody SdEngInfoBHOperateRequest request) {
SdFpssrlR entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdFpssrlR.class);
if (entity == null) {
return ResponseResult.error("数据不能为空");
public ResponseResult add(@RequestParam("data") String dataStr,
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
@RequestParam(value = "vdFiles", required = false) List<MultipartFile> vdFiles) {
try {
SdEngInfoBHOperateRequest request = objectMapper.readValue(dataStr, SdEngInfoBHOperateRequest.class);
SdFpssrlR entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdFpssrlR.class);
if (entity == null) {
return ResponseResult.error("数据不能为空");
}
// 上传附件并设置到实体图片firstImgUrl视频videoUrl
applyUploadedFiles(entity, picFiles, vdFiles);
boolean result = sdFpssrlRService.add(entity, request.getSource());
return result ? ResponseResult.success("新增成功") : ResponseResult.error("新增失败");
} catch (Exception e) {
log.error("新增过鱼自动数据失败", e);
return ResponseResult.error("新增失败: " + e.getMessage());
}
boolean result = sdFpssrlRService.add(entity, request.getSource());
return result ? ResponseResult.success("新增成功") : ResponseResult.error("新增失败");
}
@Log(module = "过鱼设施自动数据管理", value = "修改过鱼自动数据")
@PostMapping("/update")
@Operation(summary = "修改过鱼自动数据")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdFpssrlR entity = request == null || request.getEngInfo() == null ? null
: objectMapper.convertValue(request.getEngInfo(), SdFpssrlR.class);
if (entity == null || entity.getId() == null) {
return ResponseResult.error("数据或ID不能为空");
public ResponseResult update(@RequestParam("data") String dataStr,
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
@RequestParam(value = "vdFiles", required = false) List<MultipartFile> vdFiles) {
try {
SdEngInfoBHOperateRequest request = objectMapper.readValue(dataStr, SdEngInfoBHOperateRequest.class);
Map<String, Object> engInfo = request == null ? null : request.getEngInfo();
if (engInfo == null || engInfo.get("id") == null) {
return ResponseResult.error("数据或ID不能为空");
}
// 获取修改前的实体用于后续清理被替换的旧附件
SdFpssrlR before = sdFpssrlRService.getById((String) engInfo.get("id"));
List<String> oldAttachmentIds = before != null ? collectAttachmentIds(before) : Collections.emptyList();
// 上传新附件并合并回 patch map仅当本次有文件上传时才覆盖对应字段
SdFpssrlR tempEntity = objectMapper.convertValue(engInfo, SdFpssrlR.class);
applyUploadedFiles(tempEntity, picFiles, vdFiles);
if (picFiles != null && !picFiles.isEmpty()) {
engInfo.put("firstimgurl", tempEntity.getFirstimgurl());
}
if (vdFiles != null && !vdFiles.isEmpty()) {
engInfo.put("videourl", tempEntity.getVideourl());
}
boolean result = sdFpssrlRService.update(engInfo, request.getSource());
if (result) {
// 清理被替换的旧附件
SdFpssrlR after = sdFpssrlRService.getById((String) engInfo.get("id"));
deleteReplacedFiles(oldAttachmentIds, collectAttachmentIds(after));
}
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
} catch (Exception e) {
log.error("修改过鱼自动数据失败", e);
return ResponseResult.error("修改失败: " + e.getMessage());
}
boolean result = sdFpssrlRService.update(entity, request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}
@Log(module = "过鱼设施自动数据管理", value = "删除过鱼自动数据")
@ -95,7 +132,21 @@ public class SdFpssrlRController {
if (ids == null || ids.isEmpty()) {
return ResponseResult.error("ID不能为空");
}
// 删除前先收集所有需要清理的附件ID
List<String> allAttachmentIds = new ArrayList<>();
for (String id : ids) {
SdFpssrlR entity = sdFpssrlRService.getById(id);
if (entity != null) {
allAttachmentIds.addAll(collectAttachmentIds(entity));
}
}
boolean result = sdFpssrlRService.delete(ids, request.getSource());
if (result) {
// 删除关联的附件
deleteAttachments(allAttachmentIds);
}
return result ? ResponseResult.success("删除成功") : ResponseResult.error("删除失败");
}
@ -169,7 +220,6 @@ public class SdFpssrlRController {
try {
List<SdFpssrlAiR> result = sdFpssrlRService.processAiReportBatch(requests);
// List<String> ids = result.stream().map(SdFpssrlR::getId).collect(Collectors.toList());
log.info("AI批量上报成功共{}条", result.size());
return ResponseResult.success();
} catch (Exception e) {
@ -177,4 +227,85 @@ public class SdFpssrlRController {
return ResponseResult.error("上报失败: " + e.getMessage());
}
}
// ==================== 附件处理辅助方法 ====================
/**
* 上传图片/视频附件并追加附件ID到 firstImgUrl/videoUrl 字段与已有ID以逗号拼接
*/
private void applyUploadedFiles(SdFpssrlR entity, List<MultipartFile> picFiles, List<MultipartFile> vdFiles) {
if (picFiles != null && !picFiles.isEmpty()) {
List<String> ids = attachmentUploadService.uploadMultipartFiles(picFiles);
if (!ids.isEmpty()) {
entity.setFirstimgurl(mergeIds(entity.getFirstimgurl(), ids));
}
}
if (vdFiles != null && !vdFiles.isEmpty()) {
List<String> ids = attachmentUploadService.uploadMultipartFiles(vdFiles);
if (!ids.isEmpty()) {
entity.setVideourl(mergeIds(entity.getVideourl(), ids));
}
}
}
/**
* 将新上传的附件ID列表追加到已有ID字符串后面逗号分隔
*/
private String mergeIds(String existing, List<String> ids) {
String newIds = ids.stream()
.filter(StrUtil::isNotBlank)
.collect(Collectors.joining(","));
if (StrUtil.isBlank(newIds)) {
return existing;
}
return StrUtil.isBlank(existing) ? newIds : existing + "," + newIds;
}
/**
* 收集实体中 firstImgUrl/videoUrl 字段的附件ID
*/
private List<String> collectAttachmentIds(SdFpssrlR entity) {
List<String> ids = new ArrayList<>();
if (entity == null) {
return ids;
}
if (StrUtil.isNotBlank(entity.getFirstimgurl())) {
Arrays.stream(entity.getFirstimgurl().split(","))
.map(String::trim)
.filter(StrUtil::isNotBlank)
.forEach(ids::add);
}
if (StrUtil.isNotBlank(entity.getVideourl())) {
Arrays.stream(entity.getVideourl().split(","))
.map(String::trim)
.filter(StrUtil::isNotBlank)
.forEach(ids::add);
}
return ids;
}
/**
* 删除被替换的旧附件old中有但new中没有的
*/
private void deleteReplacedFiles(List<String> oldIds, List<String> newIds) {
for (String oldId : oldIds) {
if (StrUtil.isBlank(oldId)) {
continue;
}
if (!newIds.contains(oldId)) {
attachmentUploadService.deleteFile(oldId);
}
}
}
/**
* 批量删除附件
*/
private void deleteAttachments(List<String> attachmentIds) {
for (String id : attachmentIds) {
if (StrUtil.isNotBlank(id)) {
attachmentUploadService.deleteFile(id);
}
}
}
}

View File

@ -40,9 +40,8 @@ public class SdOpinfoBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdOpinfoBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdOpinfoBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdOtteBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdOtteBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdOtteBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdOtweBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdOtweBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdOtweBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdSonarBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdSonarBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdSonarBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdTeBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdTeBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdTeBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdVaBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdVaBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdVaBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdVdinfoBController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdVdinfoB entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdVdinfoB.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdVpBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdVpBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdVpBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdWeBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdWeBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdWeBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdWqBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdWqBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdWqBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -40,9 +40,8 @@ public class SdWtBHController {
@PostMapping("/update")
@Operation(summary = "修改")
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) {
SdWtBH entity = request == null || request.getEngInfo() == null ? null : objectMapper.convertValue(request.getEngInfo(), SdWtBH.class);
boolean result = service.update(entity, request == null ? null : request.getSource());
public ResponseResult update(@RequestBody SdEngInfoBHOperateRequest request) throws Exception {
boolean result = service.update(request == null ? null : request.getEngInfo(), request == null ? null : request.getSource());
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
}

View File

@ -36,4 +36,13 @@ public class MsOperationLog implements Serializable {
@TableField("RECORD_ID")
private String recordId;
@TableField("OPERATION_TYPE")
private String operationType;
/**
* 操作记录的名称瞬态字段不持久化由后端查询后填充
*/
@TableField(exist = false)
private String recordName;
}

View File

@ -14,7 +14,7 @@ public class SdEngInfoBHRequest {
private String hbrvcd;
private String rvcd;
private String reachcd;
private List<String> basIds;
private List<String> baseIds;
private List<String> hbrvcds;
private List<String> rvcds;
// private List<String> rvcds;

View File

@ -52,6 +52,10 @@ public class SdFhbtBH implements Serializable {
@FieldChinese("高程")
private BigDecimal elev;
/** 图层编码 */
@FieldChinese("图层编码")
private String layerCode;
/** 站址/位置 */
@FieldChinese("站址/位置")
private String stlc;

View File

@ -21,7 +21,7 @@ public class SdFishDictoryB implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.ASSIGN_UUID)
@TableId(type = IdType.INPUT)
@FieldChinese("主键")
private String id;
@ -105,6 +105,9 @@ public class SdFishDictoryB implements Serializable {
@FieldChinese("所属流域")
private String rvcd;
@TableField(exist = false)
private String rvcdName;
/** 洄游习性 */
@FieldChinese("洄游习性")
private String habitMigrat;

View File

@ -1,8 +1,11 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yfd.platform.annotation.FieldChinese;
import lombok.Data;
import java.io.Serializable;
@ -24,121 +27,159 @@ public class SdFpssR implements Serializable {
* 主键ID
*/
@TableId(type = IdType.ASSIGN_UUID)
@FieldChinese("主键ID")
private String id;
/**
* 过鱼设施编码
*/
@FieldChinese("过鱼设施编码")
private String stcd;
/**
* 填报时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("填报时间")
private Date tm;
/**
* 鱼种类
*/
@FieldChinese("鱼种类")
private String ftp;
@TableField(exist = false)
private String ftpName;
/**
* 鱼类规格单位cm
*/
@FieldChinese("鱼类规格")
private String fsz;
/**
* 过鱼数量单位
*/
@FieldChinese("过鱼数量")
private Integer fcnt;
/**
* 平均体重单位g
*/
@FieldChinese("平均体重")
private String fwet;
/**
* 开始日期
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("开始日期")
private Date strdt;
/**
* 结束日期
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("结束日期")
private Date enddt;
/**
* 游向0=上行,1=下行,2=上行折返,3=下行折返
*/
@FieldChinese("游向")
private Integer direction;
/**
* 当日运行次数
*/
@FieldChinese("当日运行次数")
private Integer rcnt;
/**
* 过鱼设施引用流量
*/
@FieldChinese("过鱼设施引用流量")
private BigDecimal fq;
/**
* 过鱼图片文件路径
*/
@FieldChinese("过鱼图片文件路径")
private String picpth;
/**
* 过鱼视频文件路径
*/
@FieldChinese("过鱼视频文件路径")
private String vdpth;
/**
* 年份数据时间精确到年
*/
@FieldChinese("年份")
private Integer yr;
/**
* 主要月份
*/
@FieldChinese("主要月份")
private String mouth;
/**
* 创建人
*/
@FieldChinese("创建人")
private String recordUser;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("创建时间")
private Date recordTime;
/**
* 更新人
*/
@FieldChinese("更新人")
private String modifyUser;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("更新时间")
private Date modifyTime;
/**
* 是否已删除0=未删除 1=已删除
*/
@FieldChinese("是否已删除")
private Integer isDeleted;
/**
* 删除人
*/
@FieldChinese("删除人")
private String deleteUser;
/**
* 删除时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@FieldChinese("删除时间")
private Date deleteTime;
/**
* 是否鱼苗0否 1是
*/
@FieldChinese("是否鱼苗")
private Integer isfs;
}
/**
* 水温单位
*/
@FieldChinese("水温")
private BigDecimal wtmp;
}

View File

@ -80,17 +80,21 @@ public class SdFpssrlR implements Serializable {
/**
* 鱼截图主图片url
*/
private String firstImgUrl;
@TableField("FIRSTIMGURL")
private String firstimgurl;
/**
* 鱼截图副图片url
*/
private String secondImgUrl;
@TableField("SECONDIMGURL")
private String secondimgurl;
/**
* 视频url
*/
private String videoUrl;
@TableField("VIDEOURL")
private String videourl;
/**
* 水温单位

View File

@ -1,5 +1,6 @@
package com.yfd.platform.qgc_base.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -24,6 +25,7 @@ public class EngVmsstbprptVo implements Serializable {
private String rvcdFullPath;
private String stcd;
private String stnm;
private String rstcd;
private String ennm;
private String baseId;
private String baseName;
@ -124,4 +126,124 @@ public class EngVmsstbprptVo implements Serializable {
private Integer rvcdStepSort;
private Integer rstcdStepSort;
private Integer siteStepSort;
/** 上游码头位置 */
private String updcklc;
/** 上游码头型式 */
private String updcktp;
/** 下游码头位置 */
private String downdcklc;
/** 下游码头型式 */
private String downdcktp;
/*** 过鱼时间*/
private String psfishtm;
/*** 过鱼对象*/
private String psfishtyp;
/*** 断面尺寸(长*宽*高)*/
private String syjsz;
/** 运鱼设施方式 */
private String jyyyyfs;
/** 过鱼规模 */
private Long psfishcnt;
/** 集鱼槽进口高程 */
private String syjhg;
/** 集鱼槽数量 */
private Integer syjcnt;
/** 集鱼槽流量 */
private String syjq;
/** 集鱼槽水深 */
private String syjwdp;
/** 运行时间 */
private String runtm;
/** 集诱鱼方式 */
private String syjjyyfs;
/** 投资:单位:亿元 */
private BigDecimal inv;
/** 数据监测频次 */
private Integer dtfrqcy;
/** 主要过鱼月份(多个月份用,隔开),主要过鱼月份(多个月份用,隔开),主要过鱼月份(多个月份用,隔开),主要过鱼月份(多个月份用,隔开) */
private String fpssmnmon;
/** 放流对象 */
private String zzfldx;
/** 放流对象 */
private String zzfldxName;
/** 放流地点 */
private String zzflfllc;
private String zzflfllcName;
/** 生产工艺 */
private String zzflgy;
/** 建设地点 */
private String zzfljslc;
/** 养殖模式 */
private String zzflyzms;
/** 养殖模式 */
private String zzflyzmsName;
/** 放流规模 */
private Integer zzflcnt;
/** 标记方式 */
private String zzflbjfs;
/** 承担放流任务 */
private String zzflrw;
/** 工程等级 */
private Integer zzfllvl;
/** 放流时间 */
private Date zzfltm;
/** 总占地面积 */
private BigDecimal zzflar;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date ststdt;
/** 保护方式 */
private String protmthd;
/** 保护对象 */
private String protobj;
/** 面积 */
private BigDecimal area;
/** 地点 */
private String lsdwlc;
/** 基荷发电工况 */
private BigDecimal jhfdgk;
/** 发电流量 */
private BigDecimal fdll;
/** 天然河流平均水温 */
private BigDecimal nravwt;
/** 叠梁门式进水口的门叶数量 */
private Integer dlmcnt;
/** 叠梁门式进水口的单节门叶高度 */
private String dlmhg;
/** 天然河流最高温月份多年平均水温 */
private BigDecimal nrmxavwt;
/** 天然河流最低温月份多年平均水温 */
private BigDecimal nrmnavwt;
/** 建成后坝下平均水温 */
private BigDecimal dnavwt;
/** 建成后坝下最高温月份多年平均水温 */
private BigDecimal dnmxavwt;
/** 建成后坝下最低温月份多年平均水温 */
private BigDecimal dnmnavwt;
/** 顶部高程 */
private BigDecimal frntwllhg;
/** 翻板门顶部高程 */
private BigDecimal fbmdbgc;
/** 叠梁门式进水口的最大淹没水深 */
private BigDecimal dlmmxwdp;
/** 保护范围 */
private String qxdbhfw;
/** 保护对象 */
private String protobjName;
/** 保护外围长度 */
private BigDecimal qxdbhwwcd;
/** 保护长度 */
private BigDecimal qxdbhcd;
/** 保护河段 */
private String bhhd;
/** 保护河流 */
private String bhhl;
/** 保护核心长度 */
private BigDecimal qxdbhhxcd;
}

View File

@ -0,0 +1,33 @@
package com.yfd.platform.qgc_base.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 沿程树形节点按电站(RSTCD)分组
*/
@Data
@Schema(description = "沿程树形电站节点")
public class RstcdTreeInfoVo {
@Schema(description = "电站编码")
private String rstcd;
@Schema(description = "电站名称")
private String ennm;
@Schema(description = "沿程排序")
private Integer sort;
@Schema(description = "基地编码")
private String baseId;
@Schema(description = "基地名称")
private String baseName;
@Schema(description = "下属测站列表")
private List<StcdItemVo> items = new ArrayList<>();
}

View File

@ -0,0 +1,51 @@
package com.yfd.platform.qgc_base.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 测站条目 V_MS_STBPRP_T 视图中提取的测站字段
*/
@Data
@Schema(description = "沿程树形测站条目")
public class StcdItemVo {
@Schema(description = "测站编码")
private String stcd;
@Schema(description = "测站名称")
private String stnm;
@Schema(description = "站类编码")
private String sttpCode;
@Schema(description = "站类名称")
private String sttpName;
@Schema(description = "监测方式名称")
private String mwayName;
@Schema(description = "监测方式1=人工 2=自动")
private Integer mway;
@Schema(description = "经度")
private String lgtd;
@Schema(description = "纬度")
private String lttd;
@Schema(description = "站点排序")
private Integer orderIndex;
@Schema(description = "所属电站编码")
private String rstcd;
@Schema(description = "所属电站名称")
private String ennm;
@Schema(description = "所属基地编码")
private String baseId;
@Schema(description = "所属基地名称")
private String baseName;
}

View File

@ -0,0 +1,33 @@
package com.yfd.platform.qgc_base.mapper;
import com.yfd.platform.qgc_base.domain.vo.StcdItemVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* V_MS_STBPRP_T 视图 Mapper
*/
@Mapper
public interface VMsStbprpTMapper {
/**
* 查询视图中的测站沿程数据按站类编码过滤
*/
@Select("<script>" +
"SELECT STCD, STNM, STTP_CODE AS sttpCode, STTP_NAME AS sttpName, " +
"MWAY, RSTCD, ENNM, BASE_ID AS baseId, BASE_NAME AS baseName, " +
"NVL(RSTCDSTEPSORT, 999999) AS sort, ORDER_INDEX AS orderIndex, " +
"LGTD AS lgtd, LTTD AS lttd " +
"FROM V_MS_STBPRP_T " +
"WHERE IS_DELETED = 0 " +
"<if test='sttpCodes != null and sttpCodes.size() > 0'>" +
" AND STTP_CODE IN " +
" <foreach collection='sttpCodes' item='code' open='(' separator=',' close=')'>#{code}</foreach>" +
"</if>" +
"ORDER BY NVL(RSTCDSTEPSORT, 999999), NVL(ORDER_INDEX, 999999)" +
"</script>")
List<StcdItemVo> selectBySttpCodes(@Param("sttpCodes") List<String> sttpCodes);
}

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdAiboxBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdAiboxBHService extends IService<SdAiboxBH> {
* 修改
*/
boolean update(SdAiboxBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdAimonitorBH;
import java.util.List;
import java.util.Map;
/**
* AI智能监测装置 Service 接口
@ -14,5 +15,6 @@ public interface ISdAimonitorBHService extends IService<SdAimonitorBH> {
Page<SdAimonitorBH> queryPageList(DataSourceRequest request);
boolean add(SdAimonitorBH entity, String source);
boolean update(SdAimonitorBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdArtsgBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdArtsgBHService extends IService<SdArtsgBH> {
* 修改
*/
boolean update(SdArtsgBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdDwBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdDwBHService extends IService<SdDwBH> {
* 修改
*/
boolean update(SdDwBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -17,6 +17,8 @@ import com.yfd.platform.qgc_base.domain.vo.EngPointVo;
import com.yfd.platform.qgc_base.domain.vo.EngStInfoResultVo;
import com.yfd.platform.qgc_base.domain.vo.EngVmsstbprptVo;
import com.yfd.platform.qgc_base.domain.vo.RstcdTreeInfoVo;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -101,4 +103,9 @@ public interface ISdEngInfoBHService extends IService<SdEngInfoBH> {
DataSourceResult<EngRsvrcscdRvcdVo> getRsvrcscdBRvcdList(DataSourceRequest dataSourceRequest);
DataSourceResult<EngQgcRvcdVo> getQgcRvcdList(DataSourceRequest dataSourceRequest);
/**
* 树形结构数据信息 电站沿程排序
*/
DataSourceResult<RstcdTreeInfoVo> getEngTreeByAlong(DataSourceRequest dataSourceRequest);
}

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdEqBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdEqBHService extends IService<SdEqBH> {
* 修改
*/
boolean update(SdEqBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdFbrdBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdFbrdBHService extends IService<SdFbrdBH> {
* 修改
*/
boolean update(SdFbrdBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdFhbtBH;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -28,6 +29,7 @@ public interface ISdFhbtBHService extends IService<SdFhbtBH> {
* 修改
*/
boolean update(SdFhbtBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除

View File

@ -6,6 +6,7 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdFishDictoryB;
import java.util.List;
import java.util.Map;
public interface ISdFishDictoryBService extends IService<SdFishDictoryB> {
@ -16,10 +17,21 @@ public interface ISdFishDictoryBService extends IService<SdFishDictoryB> {
boolean add(SdFishDictoryB entity, String source);
boolean update(SdFishDictoryB entity, String source);
boolean update(Map<String, Object> patchMap, String source) throws Exception;
boolean delete(List<String> ids, String source);
SdFishDictoryB getById(String id);
/**
* 检查名称是否已存在不过滤IS_DELETED因为唯一约束不区分软删除
*/
boolean existsByName(String name);
/**
* 检查名称是否已被其他记录占用排除指定ID
*/
boolean existsByNameExcludeId(String name, String excludeId);
List<SdFishDictoryB> findSimilarFish(String name, Integer limit);
}

View File

@ -7,6 +7,7 @@ import com.yfd.platform.qgc_base.domain.SdFhbtBH;
import com.yfd.platform.qgc_base.domain.SdFpssBH;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface ISdFpssBHService extends IService<SdFpssBH> {
@ -25,6 +26,7 @@ public interface ISdFpssBHService extends IService<SdFpssBH> {
boolean add(SdFpssBH sdFpssBH, String source);
boolean updateById(SdFpssBH sdFpssBH, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean deleteById(String stcd, String sttp);

View File

@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yfd.platform.qgc_base.domain.SdFpssR;
import java.util.List;
import java.util.Map;
/**
* <p>
* 过鱼设施人工数据表 服务类
@ -15,4 +18,19 @@ public interface ISdFpssRService extends IService<SdFpssR> {
* 分页查询过鱼数据
*/
Page<SdFpssR> queryPageList(Page<SdFpssR> page, String stcd, Integer yr, String ftp);
}
/**
* 新增过鱼数据
*/
boolean add(SdFpssR entity, String source);
/**
* 修改过鱼数据按前端 patch 显式更新字段 null 置空
*/
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除过鱼数据逻辑删除
*/
boolean delete(List<String> ids, String source);
}

View File

@ -8,6 +8,7 @@ import com.yfd.platform.qgc_base.domain.SdFpssrlR;
import com.yfd.platform.qgc_base.domain.SdFpssrlRAiRequest;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -27,9 +28,9 @@ public interface ISdFpssrlRService extends IService<SdFpssrlR> {
boolean add(SdFpssrlR entity, String source);
/**
* 修改
* 修改按前端 patch 显式更新字段 null 置空
*/
boolean update(SdFpssrlR entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
/**
* 删除逻辑删除

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdOpinfoBH;
import java.util.List;
import java.util.Map;
public interface ISdOpinfoBHService extends IService<SdOpinfoBH> {
Page<SdOpinfoBH> queryPageList(DataSourceRequest request);
boolean add(SdOpinfoBH entity, String source);
boolean update(SdOpinfoBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdOtteBH;
import java.util.List;
import java.util.Map;
public interface ISdOtteBHService extends IService<SdOtteBH> {
Page<SdOtteBH> queryPageList(DataSourceRequest request);
boolean add(SdOtteBH entity, String source);
boolean update(SdOtteBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdOtweBH;
import java.util.List;
import java.util.Map;
public interface ISdOtweBHService extends IService<SdOtweBH> {
Page<SdOtweBH> queryPageList(DataSourceRequest request);
boolean add(SdOtweBH entity, String source);
boolean update(SdOtweBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdSonarBH;
import java.util.List;
import java.util.Map;
public interface ISdSonarBHService extends IService<SdSonarBH> {
Page<SdSonarBH> queryPageList(DataSourceRequest request);
boolean add(SdSonarBH entity, String source);
boolean update(SdSonarBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdTeBH;
import java.util.List;
import java.util.Map;
public interface ISdTeBHService extends IService<SdTeBH> {
Page<SdTeBH> queryPageList(DataSourceRequest request);
boolean add(SdTeBH entity, String source);
boolean update(SdTeBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdVaBH;
import java.util.List;
import java.util.Map;
public interface ISdVaBHService extends IService<SdVaBH> {
Page<SdVaBH> queryPageList(DataSourceRequest request);
boolean add(SdVaBH entity, String source);
boolean update(SdVaBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdVdinfoB;
import java.util.List;
import java.util.Map;
public interface ISdVdinfoBService extends IService<SdVdinfoB> {
Page<SdVdinfoB> queryPageList(DataSourceRequest request);
boolean add(SdVdinfoB entity, String source);
boolean update(SdVdinfoB entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdVpBH;
import java.util.List;
import java.util.Map;
public interface ISdVpBHService extends IService<SdVpBH> {
Page<SdVpBH> queryPageList(DataSourceRequest request);
boolean add(SdVpBH entity, String source);
boolean update(SdVpBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdWeBH;
import java.util.List;
import java.util.Map;
public interface ISdWeBHService extends IService<SdWeBH> {
Page<SdWeBH> queryPageList(DataSourceRequest request);
boolean add(SdWeBH entity, String source);
boolean update(SdWeBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdWqBH;
import java.util.List;
import java.util.Map;
public interface ISdWqBHService extends IService<SdWqBH> {
Page<SdWqBH> queryPageList(DataSourceRequest request);
boolean add(SdWqBH entity, String source);
boolean update(SdWqBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -6,10 +6,12 @@ import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.SdWtBH;
import java.util.List;
import java.util.Map;
public interface ISdWtBHService extends IService<SdWtBH> {
Page<SdWtBH> queryPageList(DataSourceRequest request);
boolean add(SdWtBH entity, String source);
boolean update(SdWtBH entity, String source);
boolean update(Map<String, Object> engInfoPatch, String source) throws Exception;
boolean delete(List<String> stcds, String source);
}

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.annotation.FieldChinese;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
import com.yfd.platform.qgc_base.domain.MsOperationLog;
import com.yfd.platform.qgc_base.domain.MsOperationLogDetail;
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
@ -20,6 +21,7 @@ import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.SecurityUtils;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -32,11 +34,28 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Slf4j
@Service
public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper, MsOperationLog> implements IMsOperationLogService {
private static final String ENG_TABLE_NAME = "SD_ENGINFO_B_H";
/**
* 表名 (主键列, 名称列) 配置映射
* 默认主键列 = STCD名称列 = STNM无需显式配置
* 仅在主键列或名称列与默认不同的情况下才需配置
*/
private record TableNameConfig(String pkColumn, String nameColumn) {}
private static final Map<String, TableNameConfig> TABLE_NAME_CONFIG_MAP = new HashMap<>();
static {
// Engine Info: 名称列是 ENNM 而非 STNM
TABLE_NAME_CONFIG_MAP.put("SD_ENGINFO_B_H", new TableNameConfig("STCD", "ENNM"));
// Hydro Base: 主键列是 BASEID名称列是 BASENAME
TABLE_NAME_CONFIG_MAP.put("SD_HYDROBASE", new TableNameConfig("BASEID", "BASENAME"));
// Fish Dictionary: 需确认结构后配置
TABLE_NAME_CONFIG_MAP.put("SD_FISHDICTORY_B", new TableNameConfig("ID", "NAME"));
}
private static final Map<String, String> ENG_FIELD_MEANING_MAP = new LinkedHashMap<>();
// 标准日期时间格式器
private static final DateTimeFormatter DATETIME_FORMATTER =
@ -282,12 +301,15 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
@Resource
private MsOperationLogDetailMapper msOperationLogDetailMapper;
@Resource
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
@Override
public void recordEngAddLog(SdEngInfoBH engInfo, String source) {
if (engInfo == null) {
return;
}
MsOperationLog mainLog = buildMainLog(engInfo.getStcd(),"新增电站", source);
MsOperationLog mainLog = buildMainLog(engInfo.getStcd(),"新增", source,"01");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -323,7 +345,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
return;
}
MsOperationLog mainLog = buildMainLog(before.getStcd(),"修改电站", source);
MsOperationLog mainLog = buildMainLog(before.getStcd(),"修改电站", source,"02");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -360,7 +382,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
if (engInfo == null) {
return;
}
MsOperationLog mainLog = buildMainLog(engInfo.getStcd(),"删除电站", source);
MsOperationLog mainLog = buildMainLog(engInfo.getStcd(),"删除电站", source,"03");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -390,11 +412,11 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
batchInsertDetails(details);
}
private MsOperationLog buildMainLog(String recordId,String remark, String source) {
return buildMainLog(ENG_TABLE_NAME, recordId, remark, source);
private MsOperationLog buildMainLog(String recordId,String remark, String source,String operationType) {
return buildMainLog(ENG_TABLE_NAME, recordId, remark, source,operationType);
}
private MsOperationLog buildMainLog(String tableName, String recordId, String remark, String source) {
private MsOperationLog buildMainLog(String tableName, String recordId, String remark, String source,String operationType) {
MsOperationLog log = new MsOperationLog();
log.setOperator(resolveOperator());
log.setOperateTime(new Date());
@ -402,12 +424,13 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
log.setRecordId(recordId);
log.setSource(StrUtil.trimToNull(source));
log.setRemark(remark);
log.setOperationType(operationType);
return log;
}
@Override
public void recordOperationLog(String tableName, String recordId, String operation, String source) {
MsOperationLog log = buildMainLog(tableName, recordId, operation, source);
MsOperationLog log = buildMainLog(tableName, recordId, operation, source,null);
msOperationLogMapper.insert(log);
}
@ -417,7 +440,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
return;
}
// String recordId = getStcd(before);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "修改", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "修改", source,"02");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -457,7 +480,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
return;
}
// String recordId = getStcd(entity);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "新增", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "新增", source,"01");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -489,7 +512,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
}
Map<String, String> codeToNameFieldMap = buildCodeToNameFieldMap(codeToNameMetaList);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "新增", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "新增", source,"01");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -507,7 +530,9 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
}
String fieldMeaning = resolveFieldChinese(field);
Object newValue = getFieldValue(field, entity);
if(newValue == null){
continue;
}
MsOperationLogDetail detail = buildGenericDetail(mainLog.getId(), tableName, recordId, columnName,
fieldMeaning, null, newValue, "新增字段值");
@ -525,7 +550,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
return;
}
// String recordId = getStcd(entity);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "删除", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "删除", source,"03");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -560,7 +585,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
}
Map<String, String> codeToNameFieldMap = buildCodeToNameFieldMap(codeToNameMetaList);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "修改", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "修改", source,"02");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -580,9 +605,9 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
Object oldValue = getFieldValue(field, before);
Object newValue = getFieldValue(field, after);
if (newValue == null) {
continue;
}
// if (newValue == null) {
// continue;
// }
if (equalsValue(oldValue, newValue)) {
continue;
}
@ -604,7 +629,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
}
Map<String, String> codeToNameFieldMap = buildCodeToNameFieldMap(codeToNameMetaList);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "删除", source);
MsOperationLog mainLog = buildMainLog(tableName, recordId, "删除", source,"03");
msOperationLogMapper.insert(mainLog);
List<MsOperationLogDetail> details = new ArrayList<>();
@ -622,7 +647,9 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
}
String fieldMeaning = resolveFieldChinese(field);
Object oldValue = getFieldValue(field, entity);
if(oldValue == null){
continue;
}
MsOperationLogDetail detail = buildGenericDetail(mainLog.getId(), tableName, recordId, columnName,
fieldMeaning, oldValue, null, "删除字段值");
@ -931,16 +958,117 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
@Override
public Page<MsOperationLog> queryPageList(DataSourceRequest request) {
Page<MsOperationLog> msOperationLogPage = DataSourceRequestUtil.executeQuery(request, MsOperationLog.class, this);
// 批量解析操作记录名称
batchResolveRecordNames(msOperationLogPage.getRecords());
return msOperationLogPage;
}
/**
* 批量解析操作记录的名称
* tableName 分组后每张表一次批量查询名称
*/
private void batchResolveRecordNames(List<MsOperationLog> records) {
if (records == null || records.isEmpty()) {
return;
}
// tableName 分组收集 recordId
Map<String, List<String>> tableRecordIdsMap = new LinkedHashMap<>();
for (MsOperationLog log : records) {
if (StrUtil.isNotBlank(log.getTableName()) && StrUtil.isNotBlank(log.getRecordId())) {
tableRecordIdsMap.computeIfAbsent(log.getTableName(), k -> new ArrayList<>())
.add(log.getRecordId());
}
}
// 每个表批量查询名称
for (Map.Entry<String, List<String>> entry : tableRecordIdsMap.entrySet()) {
String tableName = entry.getKey();
List<String> recordIds = entry.getValue();
if (recordIds.isEmpty()) {
continue;
}
// 获取表配置
TableNameConfig config = TABLE_NAME_CONFIG_MAP.get(tableName);
String pkColumn;
String nameColumn;
if (config != null) {
pkColumn = config.pkColumn();
nameColumn = config.nameColumn();
} else {
// 默认主键列 = STCD名称列 = STNM
pkColumn = "STCD";
nameColumn = "STNM";
}
// 去重后构建 IN 参数
Set<String> distinctIds = new LinkedHashSet<>(recordIds);
Map<String, Object> paramMap = new HashMap<>();
String inPlaceholders = buildInPlaceholders(distinctIds, paramMap);
// 注意如果配置的表在数据库中不存在跳过
try {
String sql = "SELECT " + pkColumn + " AS pkVal, " + nameColumn + " AS nameVal " +
"FROM " + tableName +
" WHERE " + pkColumn + " IN (" + inPlaceholders + ")" +
" AND NVL(IS_DELETED, 0) = 0";
List<Map<String, Object>> results = microservicDynamicSQLMapper.getAllList(sql, paramMap);
// 构建 pkVal nameVal 映射
Map<String, String> nameMap = new HashMap<>();
for (Map<String, Object> row : results) {
Object pkObj = row.get("PKVAL");
Object nameObj = row.get("NAMEVAL");
if (pkObj != null && nameObj != null) {
nameMap.put(String.valueOf(pkObj), String.valueOf(nameObj));
}
}
// 回填 recordName
for (MsOperationLog log : records) {
if (tableName.equals(log.getTableName())) {
String name = nameMap.get(log.getRecordId());
if (name != null) {
log.setRecordName(name);
}
}
}
} catch (Exception e) {
// 表不存在或查询失败时静默跳过
log.warn("批量解析记录名称失败, tableName={}", tableName, e);
}
}
}
/**
* 构建 IN 子句占位符 #{map.p0}, #{map.p1}, ...
*/
private String buildInPlaceholders(Set<String> ids, Map<String, Object> paramMap) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (String id : ids) {
if (i > 0) {
sb.append(", ");
}
String key = "p" + i;
sb.append("#{map.").append(key).append("}");
paramMap.put(key, id);
i++;
}
return sb.toString();
}
@Override
public List<MsOperationLogDetail> getDetailByMainId(String mainId) {
if (StringUtils.isBlank(mainId)) {
return new ArrayList<>();
}
LambdaQueryWrapper<MsOperationLogDetail> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsOperationLogDetail::getMainId, mainId);
wrapper.eq(MsOperationLogDetail::getMainId, mainId)
.notIn(MsOperationLogDetail::getFieldCode,
"RECORD_USER", "RECORD_TIME", "MODIFY_USER", "MODIFY_TIME",
"IS_DELETED", "DELETE_USER", "DELETE_TIME");
return msOperationLogDetailMapper.selectList(wrapper);
}

View File

@ -0,0 +1,146 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DictCodeToNameConverter;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 公共 Patch 更新辅助工具按前端 Map patch 显式更新实体字段 null 值置空
* <p>
* MyBatis-Plus updateById 默认忽略 null 字段前端传 "baseId": null 表示要将该字段置空
* 通过本工具 engInfoPatch.containsKey(fieldName) 判断前端显式传入的字段
* null 值使用 SET column = NULL 实现置空
* </p>
*
* <pre>
* 使用示例
* &#64;Resource
* private PatchUpdateHelper patchUpdateHelper;
*
* public boolean update(Map&lt;String, Object&gt; engInfoPatch, String source) throws Exception {
* return patchUpdateHelper.execute(
* this, engInfoPatch, source, TABLE_NAME, SdWtBH.class,
* TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
* }
* </pre>
*/
@Component
public class PatchUpdateHelper {
@Resource
private ObjectMapper objectMapper;
@Resource
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
/**
* 执行 patch 更新默认主键字段为 "stcd"
*
* @see #execute(IService, Map, String, String, Class, Set, List, String)
*/
public <T> boolean execute(
IService<T> service,
Map<String, Object> engInfoPatch,
String source,
String tableName,
Class<T> entityClass,
Set<String> transientFields,
List<CodeToNameMetadataBo> codeToNameMetaList) throws Exception {
return execute(service, engInfoPatch, source, tableName, entityClass, transientFields, codeToNameMetaList, "stcd");
}
/**
* 执行 patch 更新仅更新前端显式传入的字段包括 null 未传入的字段保持原值
*
* @param service 对应实体的 IService用于 getById update
* @param engInfoPatch 前端传入的字段 Mapkey=字段名, value=字段值, 显式包含 null
* @param source 操作来源用于日志
* @param tableName 数据库表名用于日志
* @param entityClass 实体类
* @param transientFields 需跳过的瞬态字段集合 @TableField(exist=false)serialVersionUID
* @param codeToNameMetaList 字典代码转名称配置用于操作日志
* @param pkFieldName 主键 Java 字段名 "stcd""id"
* @param <T> 实体类型
* @return true=更新成功
* @throws Exception Jackson 类型转换异常等
*/
public <T> boolean execute(
IService<T> service,
Map<String, Object> engInfoPatch,
String source,
String tableName,
Class<T> entityClass,
Set<String> transientFields,
List<CodeToNameMetadataBo> codeToNameMetaList,
String pkFieldName) throws Exception {
Object pkValue = engInfoPatch == null ? null : engInfoPatch.get(pkFieldName);
if (isEmptyPk(pkValue)) {
throw new BizException("主键不能为空");
}
T before = service.getById((String) pkValue);
if (before == null) {
throw new BizException("记录不存在: " + pkValue);
}
T after = entityClass.getDeclaredConstructor().newInstance();
BeanUtil.copyProperties(before, after);
objectMapper.updateValue(after, engInfoPatch);
String pkColumn = StrUtil.toUnderlineCase(pkFieldName).toUpperCase();
UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq(pkColumn, pkValue);
boolean hasUpdate = false;
for (Field field : entityClass.getDeclaredFields()) {
String fieldName = field.getName();
if (transientFields.contains(fieldName) || pkFieldName.equals(fieldName)) {
continue;
}
if (!engInfoPatch.containsKey(fieldName)) {
continue;
}
String column = StrUtil.toUnderlineCase(fieldName).toUpperCase();
field.setAccessible(true);
Object value = field.get(after);
if (value == null) {
updateWrapper.setSql(column + " = NULL");
} else {
updateWrapper.set(column, value);
}
hasUpdate = true;
}
if (!hasUpdate) {
return true;
}
boolean result = service.update(updateWrapper);
if (result) {
dictCodeToNameConverter.convertCodeToName(before, codeToNameMetaList);
dictCodeToNameConverter.convertCodeToName(after, codeToNameMetaList);
msOperationLogService.recordModifyDetailLog(String.valueOf(pkValue), tableName, before, after, source, codeToNameMetaList);
}
return result;
}
private boolean isEmptyPk(Object value) {
if (value == null) return true;
if (value instanceof String) return StrUtil.isBlank((String) value);
return false;
}
}

View File

@ -1,24 +1,26 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdAiboxBH;
import com.yfd.platform.qgc_base.mapper.SdAiboxBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdAiboxBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdAiboxBHServiceImpl extends ServiceImpl<SdAiboxBHMapper, SdAiboxBH> implements ISdAiboxBHService {
@ -31,6 +33,14 @@ public class SdAiboxBHServiceImpl extends ServiceImpl<SdAiboxBHMapper, SdAiboxBH
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "bldsttCodeName", "usflName", "dtinName", "mwayName", "ennm", "baseName", "rvnm", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
* <p>
@ -71,6 +81,11 @@ public class SdAiboxBHServiceImpl extends ServiceImpl<SdAiboxBHMapper, SdAiboxBH
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdAiboxBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -92,6 +107,14 @@ public class SdAiboxBHServiceImpl extends ServiceImpl<SdAiboxBHMapper, SdAiboxBH
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdAiboxBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdAimonitorBH;
import com.yfd.platform.qgc_base.mapper.SdAimonitorBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdAimonitorBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* AI智能监测装置 Service 实现类
@ -33,6 +31,13 @@ public class SdAimonitorBHServiceImpl extends ServiceImpl<SdAimonitorBHMapper, S
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "bldsttCodeName", "dtinName", "mwayName", "ennm", "baseName", "rvnm", "serialVersionUID");
private static final List<CodeToNameMetadataBo> CODE_TO_NAME_META_LIST = new ArrayList<>();
@ -57,6 +62,11 @@ public class SdAimonitorBHServiceImpl extends ServiceImpl<SdAimonitorBHMapper, S
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdAimonitorBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -78,6 +88,14 @@ public class SdAimonitorBHServiceImpl extends ServiceImpl<SdAimonitorBHMapper, S
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdAimonitorBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,21 +1,24 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdArtsgBH;
import com.yfd.platform.qgc_base.mapper.SdArtsgBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdArtsgBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdArtsgBHServiceImpl extends ServiceImpl<SdArtsgBHMapper, SdArtsgBH> implements ISdArtsgBHService {
@ -24,6 +27,13 @@ public class SdArtsgBHServiceImpl extends ServiceImpl<SdArtsgBHMapper, SdArtsgBH
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "ennm", "baseName", "rvnm", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -64,6 +74,11 @@ public class SdArtsgBHServiceImpl extends ServiceImpl<SdArtsgBHMapper, SdArtsgBH
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdArtsgBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -85,6 +100,14 @@ public class SdArtsgBHServiceImpl extends ServiceImpl<SdArtsgBHMapper, SdArtsgBH
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdArtsgBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdDwBH;
import com.yfd.platform.qgc_base.mapper.SdDwBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdDwBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdDwBHServiceImpl extends ServiceImpl<SdDwBHMapper, SdDwBH> implements ISdDwBHService {
@ -30,6 +28,13 @@ public class SdDwBHServiceImpl extends ServiceImpl<SdDwBHMapper, SdDwBH> impleme
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "baseName", "ennm", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -66,6 +71,11 @@ public class SdDwBHServiceImpl extends ServiceImpl<SdDwBHMapper, SdDwBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdDwBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -87,6 +97,14 @@ public class SdDwBHServiceImpl extends ServiceImpl<SdDwBHMapper, SdDwBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdDwBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -23,23 +23,12 @@ import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.common.GroupHelper;
import com.yfd.platform.common.GroupingInfo;
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.vo.*;
import com.yfd.platform.qgc_data.domain.SysUserDataScope;
import com.yfd.platform.qgc_data.mapper.SysUserDataScopeMapper;
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
import com.yfd.platform.qgc_base.domain.vo.DataScopeApplyResult;
import com.yfd.platform.qgc_base.domain.SdEngInfoBHRequest;
import com.yfd.platform.qgc_base.domain.vo.EngAlarmPointVo;
import com.yfd.platform.qgc_base.domain.vo.EngBaseInfoVo;
import com.yfd.platform.qgc_base.domain.vo.EngEiaapprovalVo;
import com.yfd.platform.qgc_base.domain.vo.EngOperatVo;
import com.yfd.platform.qgc_base.domain.vo.EngQgcRvcdVo;
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdBVo;
import com.yfd.platform.qgc_base.domain.vo.EngRsvrcscdRvcdVo;
import com.yfd.platform.qgc_base.domain.vo.EngPointVo;
import com.yfd.platform.qgc_base.domain.vo.EngStbprpDataVo;
import com.yfd.platform.qgc_base.domain.vo.EngStBaseInfoVo;
import com.yfd.platform.qgc_base.domain.vo.EngStInfoResultVo;
import com.yfd.platform.qgc_base.domain.vo.EngVmsstbprptVo;
import com.yfd.platform.qgc_base.mapper.SdEngInfoBHMapper;
import com.yfd.platform.qgc_base.service.IDataScopeFilterService;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
@ -65,7 +54,7 @@ import java.util.stream.Collectors;
*/
@Service
public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEngInfoBH> implements ISdEngInfoBHService {
private static final String TABLE_NAME = "SD_FISHDICTORY_B";
private static final String TABLE_NAME = "SD_ENGINFO_B_H";
private static final Map<String, String> ENG_CODE_NAME_FIELD_MAP = new LinkedHashMap<>();
@Resource
private RedisCacheUtil redisCacheUtil;
@ -146,6 +135,14 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@Resource
private ObjectMapper objectMapper;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("usflName", "sttpName", "bldsttCodeName", "engtpName", "scrscName", "prgrName", "fnName", "adjustEngName", "ishvrgrgName", "rgcpName", "dmatName", "dmtpName", "dvtpName", "cntpName", "blsysName", "impdstrzName", "chngrdName", "chiefbasinengName", "dtinEnvName", "runStateName", "warnStateName", "coenvwStateName", "serialVersionUID");
@Resource
private IAdminAuthService adminAuthService;
@ -207,6 +204,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@Cacheable(cacheNames = "engInfoCache#3600", keyGenerator = "cacheKeyGenerator")
public List<SdEngInfoBH> selectForDropdownCached(SdEngInfoBHRequest sdEngInfoBHRequest) {
String baseId = sdEngInfoBHRequest.getBaseId();
List<String> baseIds = sdEngInfoBHRequest.getBaseIds();
String hbrvcd = sdEngInfoBHRequest.getHbrvcd();
String ennm = sdEngInfoBHRequest.getEnnm();
String rvcd = sdEngInfoBHRequest.getRvcd();
@ -219,6 +217,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
.eq(StrUtil.isNotBlank(reachcd), SdEngInfoBH::getReachcd, reachcd)
.eq(StrUtil.isNotBlank(rvcd), SdEngInfoBH::getRvcd, rvcd)
.in(rvcds != null && !rvcds.isEmpty(), SdEngInfoBH::getReachcd, rvcds)
.in(baseIds != null && !baseIds.isEmpty(), SdEngInfoBH::getBaseId, baseIds)
.in(hbrvcds != null && !hbrvcds.isEmpty(), SdEngInfoBH::getHbrvcd, hbrvcds)
.like(StringUtils.hasText(ennm), SdEngInfoBH::getEnnm, ennm)
.select(SdEngInfoBH::getStcd, SdEngInfoBH::getEnnm, SdEngInfoBH::getReachcdName, SdEngInfoBH::getYrgeb, SdEngInfoBH::getBaseId)
@ -299,6 +298,11 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@CacheEvict(cacheNames = "engInfoCache", allEntries = true)
@Transactional(rollbackFor = Exception.class)
public boolean addEngInfo(SdEngInfoBH engInfo, String source) {
if (engInfo == null || StrUtil.isBlank(engInfo.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(engInfo.getStcd());
// fillRelatedNameFields(engInfo);
boolean result = this.save(engInfo);
if (result) {
@ -334,29 +338,10 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateEngInfo(Map<String, Object> engInfoPatch, String source) throws JsonMappingException {
Map<String, Object> filteredPatch = filterEngInfoPatchFields(engInfoPatch);
if (filteredPatch.isEmpty()) {
return false;
}
String stcd = toTextValue(filteredPatch.get("stcd"));
if (!StringUtils.hasText(stcd)) {
return false;
}
SdEngInfoBH before = this.getById(stcd);
if (before == null) {
return false;
}
SdEngInfoBH after = BeanUtil.copyProperties(before, SdEngInfoBH.class);
objectMapper.updateValue(after, filteredPatch);
fillRelatedNameFields(after);
boolean result = updateEngInfoByPatch(stcd, after, filteredPatch);
if (result) {
dictCodeToNameConverter.convertCodeToName(after, CODE_TO_NAME_META_LIST);
dictCodeToNameConverter.convertCodeToName(before, CODE_TO_NAME_META_LIST);
msOperationLogService.recordModifyDetailLog(before.getStcd(),TABLE_NAME,before, after, source, CODE_TO_NAME_META_LIST);
}
return result;
public boolean updateEngInfo(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdEngInfoBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
private boolean updateEngInfoByPatch(String stcd, SdEngInfoBH after, Map<String, Object> engInfoPatch) {
@ -823,7 +808,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(page, sql, paramMap);
List<EngStbprpDataVo> list = new ArrayList<>();
for (Map<String, Object> row : rows) {
list.add(new EngStbprpDataVo(row));
list.add(new EngStbprpDataVo(convertKeysToCamelCase(row)));
}
result.setData(list);
result.setTotal(page == null ? list.size() : page.getTotal());
@ -833,15 +818,44 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
GroupingInfo[] groupInfos = loadOptions == null ? new GroupingInfo[0] : loadOptions.getGroup();
String groupSql = buildStbprpDataGroupSql(detailSql, request.getGroup(), tableMetaList);
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, groupSql, paramMap);
List<Map<String, Object>> camelRows = new ArrayList<>();
for (Map<String, Object> row : rows) {
camelRows.add(convertKeysToCamelCase(row));
}
if (Boolean.TRUE.equals(request.getGroupResultFlat())) {
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().faltGroup(rows, Arrays.asList(groupInfos)));
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().faltGroup(camelRows, Arrays.asList(groupInfos)));
} else {
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().group(rows, Arrays.asList(groupInfos)));
result.setData((List<EngStbprpDataVo>) (List<?>) new GroupHelper().group(camelRows, Arrays.asList(groupInfos)));
}
result.setTotal((long) rows.size());
return result;
}
/**
* Map key ORACLE 大写/下划线格式转为 camelCase
*/
private Map<String, Object> convertKeysToCamelCase(Map<String, Object> row) {
if (CollUtil.isEmpty(row)) {
return row;
}
Map<String, Object> result = new LinkedHashMap<>(row.size());
for (Map.Entry<String, Object> entry : row.entrySet()) {
String key = entry.getKey();
if (key == null) {
result.put(null, entry.getValue());
continue;
}
// 如果已经是小写开头说明已经是 camelCase跳过转换
if (Character.isLowerCase(key.charAt(0))) {
result.put(key, entry.getValue());
continue;
}
String camelKey = StrUtil.toCamelCase(key.toLowerCase());
result.put(camelKey, entry.getValue());
}
return result;
}
private DataSourceResult<EngOperatVo> queryOperatSummaryList(DataSourceRequest dataSourceRequest,
DataSourceLoadOptionsBase loadOptions) {
StringBuilder sql = new StringBuilder();
@ -1002,75 +1016,25 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
@Override
public EngVmsstbprptVo getStInfoByStcd(String stcd) {
// 先查 V_MS_STBPRP_T 视图获取 STTP_CODE
String checkSql = "SELECT STCD, STTP_CODE FROM V_MS_STBPRP_T WHERE STCD = #{map.stcd} AND IS_DELETED = 0 AND ROWNUM = 1";
Map<String, Object> checkResult = microservicDynamicSQLMapper.getOneBySql(checkSql, Collections.singletonMap("stcd", stcd));
String sttpCode = checkResult != null ? (String) checkResult.get("STTP_CODE") : null;
if (!"ENG".equals(sttpCode)) {
// ENG直接从 V_MS_STBPRP_T 视图返回
String viewSql = "SELECT *,SWDT STSTDT FROM V_MS_STBPRP_T WHERE STCD = #{map.stcd} AND IS_DELETED = 0";
return microservicDynamicSQLMapper.getOneBySqlWithResultType(viewSql, Collections.singletonMap("stcd", stcd), EngVmsstbprptVo.class);
}
// ENG 走原有逻辑
StringBuilder sql = new StringBuilder();
sql.append("SELECT *")
.append(" FROM (")
.append(buildVmsstbprptViewSqlNew())
.append(") t WHERE 1 = 1 AND t.STCD = #{map.stcd}");
EngVmsstbprptVo vo = microservicDynamicSQLMapper.getOneBySqlWithResultType(sql.toString(), Collections.singletonMap("stcd", stcd), EngVmsstbprptVo.class);
// SdEngInfoBH entity = this.getById(stcd);
// if (entity == null) {
// return null;
// }
//
// EngBaseInfoVo vo = new EngBaseInfoVo();
// BeanUtil.copyProperties(entity, vo);
// vo.setId(entity.getStcd());
// vo.setStnm(entity.getEnnm());
//
// String sql = "SELECT " +
// "sttp.ID AS sttp, " +
// "sttp.STTP_CODE AS sttpCode, " +
// "sttp.STTP_NAME AS sttpName, " +
// "sttp.FULL_PATH AS sttpFullPath, " +
// "sttp.TREE_LEVEL AS sttpTreeLevel, " +
// "hb.BASENAME AS baseName, " +
// "hbrv.HBRVNM AS hbrvcdName, " +
// "rv.RVNM AS rvcdName, " +
// "rv.PATH AS rvcdFullPath, " +
// "addv.ADDVNM AS addvcdName, " +
// "addv.PATH AS addvcdFullPath, " +
// "country.COUNTRY_NAME AS countryName, " +
// "hy.HYNM AS hynm, " +
// "topHy.HYNM AS topHynm " +
// "FROM SD_ENGINFO_B_H eng " +
// "LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = 'ENG' " +
// " AND NVL(sttp.IS_DELETED, 0) = 0 " +
// " AND NVL(sttp.ENABLE, 1) = 1 " +
// "LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = eng.BASE_ID " +
// "LEFT JOIN SD_HBRV_DIC hbrv ON hbrv.HBRVCD = eng.HBRVCD AND hbrv.BASEID = eng.BASE_ID " +
// " AND NVL(hbrv.ENABLED, 1) = 1 " +
// "LEFT JOIN SD_RVCD_DIC rv ON rv.RVCD = eng.RVCD " +
// "LEFT JOIN SD_ADDVCD_DIC addv ON addv.ADDVCD = eng.ADDVCD " +
// "LEFT JOIN SD_COUNTRY_B country ON country.COUNTRY_ID = eng.COUNTRY AND NVL(country.ENABLED, 1) = 1 " +
// "LEFT JOIN SD_HYCD_DIC hy ON hy.HYCD = eng.HYCD " +
// "LEFT JOIN SD_HYCD_DIC topHy ON topHy.HYCD = eng.TOP_HYCD " +
// "WHERE eng.STCD = #{map.stcd}";
//
// EngBaseInfoVo extra = microservicDynamicSQLMapper.getOneBySqlWithResultType(
// sql, java.util.Collections.singletonMap("stcd", stcd), EngBaseInfoVo.class);
// if (extra != null) {
// BeanUtil.copyProperties(extra, vo, CopyOptions.create().setIgnoreNullValue(true));
// }
//
// vo.setSttpCode("ENG");
// vo.setBlprdCode(entity.getBlprd() == null ? null : String.valueOf(entity.getBlprd()));
// vo.setBlprdCcode(entity.getBlprd() == null ? null : String.valueOf(entity.getBlprd()));
// vo.setBlprdName(resolveBlprdName(entity.getBlprd()));
// vo.setBlprdCname(vo.getBlprdName());
// vo.setDtinName(resolveDtinName(entity.getDtin()));
// vo.setBldsttName(resolveBldsttName(entity.getBldstt()));
// vo.setBldsttCcode(entity.getBldsttCode() == null ? null : String.valueOf(entity.getBldsttCode()));
// vo.setBldsttCcodeName(resolveBldsttCodeName(entity.getBldsttCode()));
// vo.setDvtpName(resolveDvtpName(entity.getDvtp()));
// vo.setRgcpName(resolveRgcpName(entity.getRgcp()));
// vo.setEngtpName(resolveEngtpName(entity.getEngtp()));
// vo.setPrscName(resolvePrscName(entity.getPrsc()));
// vo.setScrscName(resolveScrscName(entity.getScrsc()));
// vo.setPrgrName(resolvePrgrName(entity.getPrgr()));
return vo;
return microservicDynamicSQLMapper.getOneBySqlWithResultType(sql.toString(), Collections.singletonMap("stcd", stcd), EngVmsstbprptVo.class);
}
@ -1320,7 +1284,7 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
"t.BASE_ID AS baseId, " +
"t.BASE_NAME AS baseName, " +
"t.HBRVCD AS hbrvcd, " +
"t.HBRVCD_NAME AS hbrvcdName, " +
"t.RVCD_NAME AS hbrvcdName, " +
"t.RVCD AS rvcd, " +
"t.RVCD_NAME AS rvcdName, " +
"t.ADDVCD AS addvcd, " +
@ -4128,4 +4092,134 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
}
}
}
// ======================== 沿程树形查询 ========================
@Override
public DataSourceResult<RstcdTreeInfoVo> getEngTreeByAlong(
DataSourceRequest dataSourceRequest) {
DataSourceResult<RstcdTreeInfoVo> result = new DataSourceResult<>();
result.setAggregates(new HashMap<>());
if (dataSourceRequest == null) {
result.setData(new ArrayList<>());
result.setTotal(0L);
return result;
}
// 使用 buildFilterCondition 动态构建查询条件
Map<String, Object> paramMap = new HashMap<>();
String filterSql = QgcQueryWrapperUtil.buildFilterCondition(
dataSourceRequest.getFilter(),
paramMap,
new int[]{0},
this::mapVmsFilterColumn
);
StringBuilder sql = new StringBuilder();
sql.append("SELECT STCD AS stcd, STNM AS stnm, ")
.append("STTP_CODE AS sttpCode, STTP_NAME AS sttpName, ")
.append("MWAY AS mway, RSTCD AS rstcd, ENNM AS ennm, ")
.append("BASE_ID AS baseId, BASE_NAME AS baseName, ")
.append("NVL(RSTCDSTEPSORT, 999999) AS rstcdStepSort, ")
.append("NVL(ORDER_INDEX, 999999) AS orderIndex, ")
.append("LGTD AS lgtd, LTTD AS lttd ")
.append("FROM V_MS_STBPRP_T ")
.append("WHERE NVL(IS_DELETED, 0) = 0");
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql);
}
sql.append(" ORDER BY NVL(RSTCDSTEPSORT, 999999), NVL(ORDER_INDEX, 999999)");
List<StcdItemVo> allItems = microservicDynamicSQLMapper
.getAllListWithResultType(sql.toString(), paramMap, StcdItemVo.class);
if (CollUtil.isEmpty(allItems)) {
result.setData(new ArrayList<>());
result.setTotal(0L);
return result;
}
// 构建树形结构 RSTCD 分组
Map<String, List<StcdItemVo>> groupedMap = new LinkedHashMap<>();
for (StcdItemVo item : allItems) {
String rstcd = StrUtil.blankToDefault(item.getRstcd(), "");
// 处理逗号分隔的多个 RSTCD一个测站关联多个电站
if (rstcd.contains(",")) {
for (String singleRstcd : rstcd.split(",")) {
String r = singleRstcd.trim();
if (StrUtil.isNotBlank(r)) {
groupedMap.computeIfAbsent(r, k -> new ArrayList<>()).add(item);
}
}
} else if (StrUtil.isNotBlank(rstcd)) {
groupedMap.computeIfAbsent(rstcd, k -> new ArrayList<>()).add(item);
} else {
// 无电站归属 other
groupedMap.computeIfAbsent("other", k -> new ArrayList<>()).add(item);
}
}
// 转换为树节点列表
List<RstcdTreeInfoVo> treeList = new ArrayList<>();
for (Map.Entry<String, List<StcdItemVo>> entry : groupedMap.entrySet()) {
String rstcd = entry.getKey();
List<StcdItemVo> items = entry.getValue();
RstcdTreeInfoVo node =
new RstcdTreeInfoVo();
if ("other".equals(rstcd)) {
node.setRstcd("other");
node.setEnnm("其它");
} else {
node.setRstcd(rstcd);
// 从测站数据中取电站名称
String ennm = items.stream()
.map(StcdItemVo::getEnnm)
.filter(StrUtil::isNotBlank)
.findFirst().orElse(rstcd);
node.setEnnm(ennm);
}
// 取第一个测站的排序和基地信息
StcdItemVo first = items.getFirst();
node.setSort(first.getOrderIndex());
node.setBaseId(first.getBaseId());
node.setBaseName(first.getBaseName());
node.setItems(items);
treeList.add(node);
}
result.setData(treeList);
result.setTotal(treeList.size());
return result;
}
/**
* V_MS_STBPRP_T 视图字段映射前端字段名 数据库列名
*/
private String mapVmsFilterColumn(String field) {
if (field == null) return null;
return switch (field) {
case "stcd" -> "STCD";
case "stnm" -> "STNM";
case "sttpCode", "sttp_code" -> "STTP_CODE";
case "sttpName", "sttp_name" -> "STTP_NAME";
case "mway" -> "MWAY";
case "rstcd" -> "RSTCD";
case "ennm" -> "ENNM";
case "baseId", "base_id" -> "BASE_ID";
case "baseName", "base_name" -> "BASE_NAME";
case "fhstcd" -> "FHSTCD";
case "lgtd" -> "LGTD";
case "lttd" -> "LTTD";
case "orderIndex", "order_index" -> "ORDER_INDEX";
case "rstcdStepSort", "rstcdstepsort" -> "RSTCDSTEPSORT";
case "isDeleted", "is_deleted" -> "IS_DELETED";
default -> null;
};
}
}

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdEqBH;
import com.yfd.platform.qgc_base.mapper.SdEqBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdEqBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdEqBHServiceImpl extends ServiceImpl<SdEqBHMapper, SdEqBH> implements ISdEqBHService {
@ -30,6 +28,13 @@ public class SdEqBHServiceImpl extends ServiceImpl<SdEqBHMapper, SdEqBH> impleme
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "ennm", "baseName", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -66,6 +71,11 @@ public class SdEqBHServiceImpl extends ServiceImpl<SdEqBHMapper, SdEqBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdEqBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -87,6 +97,14 @@ public class SdEqBHServiceImpl extends ServiceImpl<SdEqBHMapper, SdEqBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdEqBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,21 +1,24 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdFbrdBH;
import com.yfd.platform.qgc_base.mapper.SdFbrdBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdFbrdBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdFbrdBHServiceImpl extends ServiceImpl<SdFbrdBHMapper, SdFbrdBH> implements ISdFbrdBHService {
@ -27,6 +30,13 @@ public class SdFbrdBHServiceImpl extends ServiceImpl<SdFbrdBHMapper, SdFbrdBH> i
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "ennm", "baseName", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -63,6 +73,11 @@ public class SdFbrdBHServiceImpl extends ServiceImpl<SdFbrdBHMapper, SdFbrdBH> i
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdFbrdBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -84,6 +99,14 @@ public class SdFbrdBHServiceImpl extends ServiceImpl<SdFbrdBHMapper, SdFbrdBH> i
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdFbrdBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdFhbtBH;
import com.yfd.platform.qgc_base.mapper.SdFhbtBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdFhbtBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdFhbtBHServiceImpl extends ServiceImpl<SdFhbtBHMapper, SdFhbtBH> implements ISdFhbtBHService {
@ -30,6 +28,13 @@ public class SdFhbtBHServiceImpl extends ServiceImpl<SdFhbtBHMapper, SdFhbtBH> i
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "ennm", "baseName", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -67,6 +72,11 @@ public class SdFhbtBHServiceImpl extends ServiceImpl<SdFhbtBHMapper, SdFhbtBH> i
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdFhbtBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -88,6 +98,14 @@ public class SdFhbtBHServiceImpl extends ServiceImpl<SdFhbtBHMapper, SdFhbtBH> i
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdFhbtBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,6 +1,7 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -36,6 +37,14 @@ public class SdFishDictoryBServiceImpl extends ServiceImpl<SdFishDictoryBMapper,
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private PatchUpdateHelper patchUpdateHelper;
/** SdFishDictoryB 中 @TableField(exist = false) 的字段名 + serialVersionUID */
private static final Set<String> TRANSIENT_FIELDS = Set.of(
"typeName", "rareName", "specOriginName", "ptypeName",
"habitatName", "situationName", "resourceTypeName", "serialVersionUID"
);
/**
* 代码转名称元数据配置列表静态初始化
@ -95,6 +104,14 @@ public class SdFishDictoryBServiceImpl extends ServiceImpl<SdFishDictoryBMapper,
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> patchMap, String source) throws Exception {
return patchUpdateHelper.execute(
this, patchMap, source, TABLE_NAME, SdFishDictoryB.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST, "id");
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> ids, String source) {
@ -116,6 +133,29 @@ public class SdFishDictoryBServiceImpl extends ServiceImpl<SdFishDictoryBMapper,
return count > 0;
}
@Override
public boolean existsByName(String name) {
if (!StringUtils.hasText(name)) {
return false;
}
LambdaQueryWrapper<SdFishDictoryB> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SdFishDictoryB::getName, name);
return count(wrapper) > 0;
}
@Override
public boolean existsByNameExcludeId(String name, String excludeId) {
if (!StringUtils.hasText(name)) {
return false;
}
LambdaQueryWrapper<SdFishDictoryB> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SdFishDictoryB::getName, name);
if (StringUtils.hasText(excludeId)) {
wrapper.ne(SdFishDictoryB::getId, excludeId);
}
return count(wrapper) > 0;
}
@Override
public SdFishDictoryB getById(String id) {
LambdaQueryWrapper<SdFishDictoryB> wrapper = new LambdaQueryWrapper<>();

View File

@ -1,10 +1,12 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdEngInfoBH;
import com.yfd.platform.qgc_base.domain.SdFpssBH;
import com.yfd.platform.qgc_base.mapper.SdEngInfoBHMapper;
@ -14,12 +16,11 @@ import com.yfd.platform.qgc_base.service.ISdFpssBHService;
import com.yfd.platform.qgc_data.domain.SysUserDataScope;
import com.yfd.platform.qgc_data.mapper.SysUserDataScopeMapper;
import com.yfd.platform.system.service.IAdminAuthService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
@ -42,6 +43,13 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
@Resource
private IMsOperationLogService msOperationLogService;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "baseName", "dtinName", "ennm", "bldsttCodeName", "isUpName", "isDownName", "mwayName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -213,6 +221,11 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
@Override
public boolean add(SdFpssBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -234,6 +247,14 @@ public class SdFpssBHServiceImpl extends ServiceImpl<SdFpssBHMapper, SdFpssBH> i
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdFpssBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
public boolean deleteById(String stcd, String sttp) {
LambdaQueryWrapper<SdFpssBH> wrapper = new LambdaQueryWrapper<>();

View File

@ -1,15 +1,27 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.qgc_base.domain.SdFpssR;
import com.yfd.platform.qgc_base.mapper.SdFpssRMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdFpssRService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* <p>
@ -19,6 +31,30 @@ import java.util.Date;
@Service
public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> implements ISdFpssRService {
private static final String TABLE_NAME = "SD_FPSS_R";
@Resource
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("ftpName", "serialVersionUID");
/**
* 代码转名称元数据配置列表
*/
private static final List<CodeToNameMetadataBo> CODE_TO_NAME_META_LIST = new ArrayList<>();
static {
CODE_TO_NAME_META_LIST.add(CodeToNameMetadataBo.builder().codeProperty("ftp").modifyProperty("ftpName")
.dictType("DYNAMIC").dictSource("SD_FISHDICTORY_B").codeColumn("ID").nameColumn("NAME")
.filter("NVL(IS_DELETED, 0) = 0 AND NVL(ENABLE, 1) = 1").build());
}
@Override
public Page<SdFpssR> queryPageList(Page<SdFpssR> page, String stcd, Integer yr, String ftp) {
LambdaQueryWrapper<SdFpssR> wrapper = new LambdaQueryWrapper<>();
@ -35,7 +71,9 @@ public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> impl
wrapper.eq(SdFpssR::getIsDeleted, 0);
wrapper.orderByDesc(SdFpssR::getRecordTime);
return page(page, wrapper);
Page<SdFpssR> result = page(page, wrapper);
dictCodeToNameConverter.convertCodeToName(result, CODE_TO_NAME_META_LIST);
return result;
}
@Override
@ -51,14 +89,50 @@ public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> impl
return super.updateById(entity);
}
// @Override
// public boolean removeById(Object id) {
// SdFpssR entity = getById(id);
// if (entity != null) {
// entity.setIsDeleted(1);
// entity.setDeleteTime(new Date());
// return updateById(entity);
// }
// return false;
// }
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdFpssR entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new com.yfd.platform.common.exception.BizException("过鱼设施编码不能为空");
}
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
msOperationLogService.recordAddDetailLog(entity.getId(), TABLE_NAME, entity, source, CODE_TO_NAME_META_LIST);
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(this, engInfoPatch, source, TABLE_NAME, SdFpssR.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST, "id");
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> ids, String source) {
if (ids == null || ids.isEmpty()) {
return false;
}
int count = 0;
for (String id : ids) {
SdFpssR entity = this.getById(id);
if (entity == null) {
continue;
}
LambdaUpdateWrapper<SdFpssR> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(SdFpssR::getId, id);
wrapper.set(SdFpssR::getIsDeleted, 1);
wrapper.set(SdFpssR::getDeleteUser, SecurityUtils.getCurrentUsername());
wrapper.set(SdFpssR::getDeleteTime, new Date());
if (this.update(wrapper)) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
msOperationLogService.recordDeleteDetailLog(id, TABLE_NAME, entity, source, CODE_TO_NAME_META_LIST);
count++;
}
}
return count > 0;
}
}

View File

@ -13,7 +13,9 @@ import com.yfd.platform.qgc_base.mapper.SdFpssrlAiRMapper;
import com.yfd.platform.qgc_base.mapper.SdFpssrlRMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdFpssrlRService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@ -23,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* <p>
@ -40,6 +44,26 @@ public class SdFpssrlRServiceImpl extends ServiceImpl<SdFpssrlRMapper, SdFpssrlR
@Resource
private SdFpssrlAiRMapper fpssrlAiRMapper;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("stnm", "serialVersionUID");
/**
* 代码转名称元数据配置列表
*/
private static final List<CodeToNameMetadataBo> CODE_TO_NAME_META_LIST = new ArrayList<>();
static {
CODE_TO_NAME_META_LIST.add(CodeToNameMetadataBo.builder().codeProperty("ftp").modifyProperty("ftpName")
.dictType("DYNAMIC").dictSource("SD_FISHDICTORY_B").codeColumn("ID").nameColumn("NAME")
.filter("NVL(IS_DELETED, 0) = 0 AND NVL(ENABLE, 1) = 1").build());
}
@Override
public Page<SdFpssrlR> queryPageList(DataSourceRequest request) {
return DataSourceRequestUtil.executeQuery(request, SdFpssrlR.class, this);
@ -49,21 +73,18 @@ public class SdFpssrlRServiceImpl extends ServiceImpl<SdFpssrlRMapper, SdFpssrlR
@Transactional(rollbackFor = Exception.class)
public boolean add(SdFpssrlR entity, String source) {
boolean result = this.save(entity);
// if (result) {
// msOperationLogService.recordAddDetailLog(entity.getId(),TABLE_NAME, entity, source);
// }
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
msOperationLogService.recordAddDetailLog(entity.getId(), TABLE_NAME, entity, source, CODE_TO_NAME_META_LIST);
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(SdFpssrlR entity, String source) {
// SdFpssrlR before = this.getById(entity.getId());
boolean result = this.updateById(entity);
// if (result && before != null) {
// msOperationLogService.recordModifyDetailLog(entity.getId(),TABLE_NAME, before, entity, source);
// }
return result;
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(this, engInfoPatch, source, TABLE_NAME, SdFpssrlR.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST, "id");
}
@Override
@ -72,14 +93,14 @@ public class SdFpssrlRServiceImpl extends ServiceImpl<SdFpssrlRMapper, SdFpssrlR
if (ids == null || ids.isEmpty()) return false;
int count = 0;
for (String id : ids) {
// SdFpssrlR entity = getById(id);
SdFpssrlR entity = getById(id);
LambdaUpdateWrapper<SdFpssrlR> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(SdFpssrlR::getId, id);
wrapper.set(SdFpssrlR::getIsDeleted, 1);
wrapper.set(SdFpssrlR::getDeleteUser, SecurityUtils.getCurrentUsername());
wrapper.set(SdFpssrlR::getDeleteTime, new Date());
if (this.update(wrapper)) {
// msOperationLogService.recordDeleteDetailLog(id,TABLE_NAME, entity, source);
msOperationLogService.recordDeleteDetailLog(id,TABLE_NAME, entity, source);
count++;
}
}
@ -108,9 +129,9 @@ public class SdFpssrlRServiceImpl extends ServiceImpl<SdFpssrlRMapper, SdFpssrlR
entity.setFishspeed(request.getFishspeed());
entity.setDirection(request.getDirection());
entity.setFishposition(request.getFishposition());
entity.setFirstImgUrl(request.getFirstImgUrl());
entity.setSecondImgUrl(request.getSecondImgUrl());
entity.setVideoUrl(request.getVideoUrl());
entity.setFirstimgurl(request.getFirstImgUrl());
entity.setSecondimgurl(request.getSecondImgUrl());
entity.setVideourl(request.getVideoUrl());
entity.setTemperature(request.getTemperature());
entity.setWaterlevel(request.getWaterlevel());
entity.setSpeed(request.getSpeed());

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdOpinfoBH;
import com.yfd.platform.qgc_base.mapper.SdOpinfoBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdOpinfoBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdOpinfoBHServiceImpl extends ServiceImpl<SdOpinfoBHMapper, SdOpinfoBH> implements ISdOpinfoBHService {
@ -30,6 +28,13 @@ public class SdOpinfoBHServiceImpl extends ServiceImpl<SdOpinfoBHMapper, SdOpinf
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("dtinName", "ennm", "baseName", "rvnm", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -67,6 +72,11 @@ public class SdOpinfoBHServiceImpl extends ServiceImpl<SdOpinfoBHMapper, SdOpinf
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdOpinfoBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -88,6 +98,14 @@ public class SdOpinfoBHServiceImpl extends ServiceImpl<SdOpinfoBHMapper, SdOpinf
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdOpinfoBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,21 +1,24 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdOtteBH;
import com.yfd.platform.qgc_base.mapper.SdOtteBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdOtteBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdOtteBHServiceImpl extends ServiceImpl<SdOtteBHMapper, SdOtteBH> implements ISdOtteBHService {
@ -27,6 +30,13 @@ public class SdOtteBHServiceImpl extends ServiceImpl<SdOtteBHMapper, SdOtteBH> i
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "bldsttCodeName", "usflName", "dtinName", "mwayName", "ennm", "baseName", "rvnm", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -66,6 +76,11 @@ public class SdOtteBHServiceImpl extends ServiceImpl<SdOtteBHMapper, SdOtteBH> i
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdOtteBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -87,6 +102,14 @@ public class SdOtteBHServiceImpl extends ServiceImpl<SdOtteBHMapper, SdOtteBH> i
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdOtteBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,21 +1,24 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdOtweBH;
import com.yfd.platform.qgc_base.mapper.SdOtweBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdOtweBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdOtweBHServiceImpl extends ServiceImpl<SdOtweBHMapper, SdOtweBH> implements ISdOtweBHService {
@ -26,6 +29,13 @@ public class SdOtweBHServiceImpl extends ServiceImpl<SdOtweBHMapper, SdOtweBH> i
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "usflName", "dtinName", "ennm", "baseName", "rvnm", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -64,6 +74,11 @@ public class SdOtweBHServiceImpl extends ServiceImpl<SdOtweBHMapper, SdOtweBH> i
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdOtweBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -85,6 +100,14 @@ public class SdOtweBHServiceImpl extends ServiceImpl<SdOtweBHMapper, SdOtweBH> i
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdOtweBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdSonarBH;
import com.yfd.platform.qgc_base.mapper.SdSonarBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdSonarBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdSonarBHServiceImpl extends ServiceImpl<SdSonarBHMapper, SdSonarBH> implements ISdSonarBHService {
@ -29,6 +27,13 @@ public class SdSonarBHServiceImpl extends ServiceImpl<SdSonarBHMapper, SdSonarBH
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "bldsttCodeName", "usflName", "dtinName", "mwayName", "ennm", "baseName", "rvnm", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -69,6 +74,11 @@ public class SdSonarBHServiceImpl extends ServiceImpl<SdSonarBHMapper, SdSonarBH
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdSonarBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -90,6 +100,14 @@ public class SdSonarBHServiceImpl extends ServiceImpl<SdSonarBHMapper, SdSonarBH
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdSonarBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,21 +1,24 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdTeBH;
import com.yfd.platform.qgc_base.mapper.SdTeBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdTeBHService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdTeBHServiceImpl extends ServiceImpl<SdTeBHMapper, SdTeBH> implements ISdTeBHService {
@ -26,6 +29,13 @@ public class SdTeBHServiceImpl extends ServiceImpl<SdTeBHMapper, SdTeBH> impleme
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "dtinName", "ennm", "baseName", "rvnm", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -64,6 +74,11 @@ public class SdTeBHServiceImpl extends ServiceImpl<SdTeBHMapper, SdTeBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdTeBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -85,6 +100,14 @@ public class SdTeBHServiceImpl extends ServiceImpl<SdTeBHMapper, SdTeBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdTeBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdVaBH;
import com.yfd.platform.qgc_base.mapper.SdVaBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdVaBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdVaBHServiceImpl extends ServiceImpl<SdVaBHMapper, SdVaBH> implements ISdVaBHService {
@ -29,6 +27,13 @@ public class SdVaBHServiceImpl extends ServiceImpl<SdVaBHMapper, SdVaBH> impleme
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "usflName", "dtinName", "ennm", "baseName", "bldsttCodeName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -65,6 +70,11 @@ public class SdVaBHServiceImpl extends ServiceImpl<SdVaBHMapper, SdVaBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdVaBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -86,6 +96,14 @@ public class SdVaBHServiceImpl extends ServiceImpl<SdVaBHMapper, SdVaBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdVaBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -4,20 +4,21 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdVdinfoB;
import com.yfd.platform.qgc_base.mapper.SdVdinfoBMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdVdinfoBService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.checkerframework.checker.units.qual.C;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdVdinfoBServiceImpl extends ServiceImpl<SdVdinfoBMapper, SdVdinfoB> implements ISdVdinfoBService {
@ -28,6 +29,13 @@ public class SdVdinfoBServiceImpl extends ServiceImpl<SdVdinfoBMapper, SdVdinfoB
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
private static final Set<String> TRANSIENT_FIELDS = Set.of("sttpName", "ennm", "rvnm", "addvcdName", "baseName", "bldsttCodeName", "dtinName", "serialVersionUID");
/**
* 代码转名称元数据配置列表静态初始化
@ -67,6 +75,11 @@ public class SdVdinfoBServiceImpl extends ServiceImpl<SdVdinfoBMapper, SdVdinfoB
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdVdinfoB entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
String mntp = entity.getMntp();
if (StrUtil.isBlank(mntp)) {
entity.setMntp("实时视频");
@ -91,6 +104,14 @@ public class SdVdinfoBServiceImpl extends ServiceImpl<SdVdinfoBMapper, SdVdinfoB
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdVdinfoB.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdVpBH;
import com.yfd.platform.qgc_base.mapper.SdVpBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdVpBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdVpBHServiceImpl extends ServiceImpl<SdVpBHMapper, SdVpBH> implements ISdVpBHService {
@ -29,7 +27,15 @@ public class SdVpBHServiceImpl extends ServiceImpl<SdVpBHMapper, SdVpBH> impleme
private IMsOperationLogService msOperationLogService;
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
/** SdVpBH 中 @TableField(exist = false) 的字段名 + serialVersionUID */
private static final Set<String> TRANSIENT_FIELDS = Set.of(
"sttpName", "dtinName", "ennm", "baseName", "bldsttCodeName", "serialVersionUID"
);
/**
* 代码转名称元数据配置列表静态初始化
* <p>
@ -65,6 +71,11 @@ public class SdVpBHServiceImpl extends ServiceImpl<SdVpBHMapper, SdVpBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdVpBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -85,6 +96,14 @@ public class SdVpBHServiceImpl extends ServiceImpl<SdVpBHMapper, SdVpBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdVpBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,8 +1,10 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdWeBH;
import com.yfd.platform.qgc_base.mapper.SdWeBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
@ -10,12 +12,12 @@ import com.yfd.platform.qgc_base.service.ISdWeBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.StcdUniqueValidator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
@Service
public class SdWeBHServiceImpl extends ServiceImpl<SdWeBHMapper, SdWeBH> implements ISdWeBHService {
@ -27,7 +29,15 @@ public class SdWeBHServiceImpl extends ServiceImpl<SdWeBHMapper, SdWeBH> impleme
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
/** SdWeBH 中 @TableField(exist = false) 的字段名 + serialVersionUID */
private static final Set<String> TRANSIENT_FIELDS = Set.of(
"sttpName", "dtinName", "ennm", "baseName", "rvnm", "bldsttCodeName", "serialVersionUID"
);
/**
* 代码转名称元数据配置列表静态初始化
* <p>
@ -66,6 +76,11 @@ public class SdWeBHServiceImpl extends ServiceImpl<SdWeBHMapper, SdWeBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdWeBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -87,6 +102,14 @@ public class SdWeBHServiceImpl extends ServiceImpl<SdWeBHMapper, SdWeBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdWeBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,24 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdWqBH;
import com.yfd.platform.qgc_base.mapper.SdWqBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdWqBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdWqBHServiceImpl extends ServiceImpl<SdWqBHMapper, SdWqBH> implements ISdWqBHService {
@ -30,7 +28,16 @@ public class SdWqBHServiceImpl extends ServiceImpl<SdWqBHMapper, SdWqBH> impleme
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
/** SdWqBH 中 @TableField(exist = false) 的字段名 + serialVersionUID */
private static final Set<String> TRANSIENT_FIELDS = Set.of(
"sttpName", "wwqtgName", "bldsttCodeName", "dtinName",
"dtinTypeName", "mwayName", "ennm", "baseName", "serialVersionUID"
);
/**
* 代码转名称元数据配置列表静态初始化
* <p>
@ -68,6 +75,11 @@ public class SdWqBHServiceImpl extends ServiceImpl<SdWqBHMapper, SdWqBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdWqBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -88,6 +100,14 @@ public class SdWqBHServiceImpl extends ServiceImpl<SdWqBHMapper, SdWqBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdWqBH.class,
TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -1,25 +1,22 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.exception.BizException;
import com.yfd.platform.qgc_base.domain.SdWtBH;
import com.yfd.platform.qgc_base.mapper.SdWtBHMapper;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.ISdWtBHService;
import com.yfd.platform.utils.CodeToNameMetadataBo;
import com.yfd.platform.utils.DataSourceRequestUtil;
import com.yfd.platform.utils.DictCodeToNameConverter;
import com.yfd.platform.utils.SecurityUtils;
import com.yfd.platform.utils.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
public class SdWtBHServiceImpl extends ServiceImpl<SdWtBHMapper, SdWtBH> implements ISdWtBHService {
@ -32,7 +29,16 @@ public class SdWtBHServiceImpl extends ServiceImpl<SdWtBHMapper, SdWtBH> impleme
@Resource
private DictCodeToNameConverter dictCodeToNameConverter;
@Resource
private StcdUniqueValidator stcdUniqueValidator;
@Resource
private PatchUpdateHelper patchUpdateHelper;
/** SdWtBH 中 @TableField(exist = false) 的字段名 + serialVersionUID */
private static final Set<String> WT_TRANSIENT_FIELDS = Set.of(
"sttpName", "bldsttCodeName", "dtinName", "dtinTypeName",
"mwayName", "ennm", "baseName", "serialVersionUID"
);
/**
* 代码转名称元数据配置列表静态初始化
* <p>
@ -70,6 +76,11 @@ public class SdWtBHServiceImpl extends ServiceImpl<SdWtBHMapper, SdWtBH> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public boolean add(SdWtBH entity, String source) {
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
throw new BizException("站点编码不能为空");
}
// 检查 STCD V_MS_STBPRP_T 视图中是否已存在
stcdUniqueValidator.throwIfExists(entity.getStcd());
boolean result = this.save(entity);
if (result) {
dictCodeToNameConverter.convertCodeToName(entity, CODE_TO_NAME_META_LIST);
@ -91,6 +102,14 @@ public class SdWtBHServiceImpl extends ServiceImpl<SdWtBHMapper, SdWtBH> impleme
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(Map<String, Object> engInfoPatch, String source) throws Exception {
return patchUpdateHelper.execute(
this, engInfoPatch, source, TABLE_NAME, SdWtBH.class,
WT_TRANSIENT_FIELDS, CODE_TO_NAME_META_LIST);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean delete(List<String> stcds, String source) {

View File

@ -112,8 +112,9 @@ public class FishDraftDataController {
@PostMapping("/statistics")
@Operation(summary = "过鱼到数统计(按用户月度汇总,支持流域/电站多选过滤)")
public ResponseResult statistics(@RequestBody DataSourceRequest dataSourceRequest) {
Page<FishStatisticsVO> result = fishStatisticsService.queryPage(dataSourceRequest);
public ResponseResult statistics(@RequestBody DataSourceRequest dataSourceRequest,
@RequestHeader(value = "Tenant_id", required = false) String tenantId) {
Page<FishStatisticsVO> result = fishStatisticsService.queryPage(dataSourceRequest, tenantId);
return ResponseResult.successData(result);
}
@ -1227,8 +1228,9 @@ public class FishDraftDataController {
if (data.getDirection() == null || data.getDirection().isEmpty()) {
addWarning(warnings, "direction");
} else {
String direction = fishImportService.resolveDirection(data.getDirection().trim(), importRow);
if (direction == null) {
String direction = fishImportService.resolveDirection(data.getStnm(),data.getDirection().trim(), importRow);
if (direction == null||importRow.getWarnings().contains("direction")) {
data.setDirection(direction);
addWarning(warnings, "direction");
}
}

View File

@ -10,10 +10,12 @@ public interface FishStatisticsMapper {
List<FishStatisticsVO> queryStatistics(@Param("basinCode") String basinCode,
@Param("stationCode") String stationCode,
@Param("reportMonth") String reportMonth,
@Param("tenantId") String tenantId,
@Param("startRow") int startRow,
@Param("endRow") int endRow);
int countStatistics(@Param("basinCode") String basinCode,
@Param("stationCode") String stationCode,
@Param("reportMonth") String reportMonth);
@Param("reportMonth") String reportMonth,
@Param("tenantId") String tenantId);
}

View File

@ -42,7 +42,7 @@ public interface IFishImportService {
String resolveBaseCode(String code,String baseName);
String resolveRiverCode(String code,String riverName);
String resolveHbrvcdCode(String code,String riverName);
String resolveDirection(String direction, FishImportResult.FishImportRow importRow);
String resolveDirection(String stnm,String direction, FishImportResult.FishImportRow importRow);
String resolveIsfs(String value, FishImportResult.FishImportRow importRow);

View File

@ -6,5 +6,5 @@ import com.yfd.platform.qgc_data.domain.vo.FishStatisticsVO;
public interface IFishStatisticsService {
Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest);
Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest, String tenantId);
}

View File

@ -342,12 +342,16 @@ public class FishImportServiceImpl implements IFishImportService {
FishImportResult.FishImportRow importRow = new FishImportResult.FishImportRow(rowIndex);
FishDraftData data = new FishDraftData();
data.setId(UUID.randomUUID().toString());
String stnm=null;
for (Map.Entry<Integer, String> entry : columnIndexMap.entrySet()) {
Integer columnIndex = entry.getKey();
String fieldName = entry.getValue();
Cell cell = row.getCell(columnIndex);
String cellValue = getCellStringValue(cell);
if("stnm".equals(fieldName)){
stnm=cellValue;
}
try {
switch (fieldName) {
case "stationName":
@ -509,7 +513,7 @@ public class FishImportServiceImpl implements IFishImportService {
importRow.getWarnings().add(fieldName);
data.setDirection(cellValue.trim());
} else {
String direction = resolveDirection(cellValue.trim(), importRow);
String direction = resolveDirection(stnm,cellValue.trim(), importRow);
data.setDirection(direction);
}
break;
@ -1372,25 +1376,109 @@ public class FishImportServiceImpl implements IFishImportService {
return facilityName;
}
public String resolveDirection(String direction, FishImportResult.FishImportRow importRow) {
public String resolveDirection(String stnm, String direction, FishImportResult.FishImportRow importRow) {
if (direction == null) {
return null;
}
String lowerName = direction.toLowerCase().trim();
if (lowerName.contains("上行") && lowerName.contains("折返")) {
// 独立判断四种方向类型按优先级从高到低
boolean isUpReturn = lowerName.contains("上行") && lowerName.contains("折返");
boolean isDownReturn = lowerName.contains("下行") && lowerName.contains("折返");
boolean isUp = lowerName.contains("上行") && !isUpReturn; // 排除上行折返
boolean isDown = lowerName.contains("下行") && !isDownReturn; // 排除下行折返
// 判断 direction 是否为字典编码
boolean isDictCode = "0".equals(direction) || "1".equals(direction) ||
"2".equals(direction) || "3".equals(direction);
if (importRow.getWarnings().contains("stcd")) {
importRow.getWarnings().add("direction");
// 如果是字典编码返回对应的中文否则返回原始数据
return isDictCode ? getDirectionChinese(direction) : direction;
}
// 如果 direction 本身是字典编码0/1/2/3直接识别
if ("0".equals(direction)) {
isUp = true;
isUpReturn = false;
} else if ("1".equals(direction)) {
isDown = true;
isDownReturn = false;
} else if ("2".equals(direction)) {
isUpReturn = true;
isUp = false;
} else if ("3".equals(direction)) {
isDownReturn = true;
isDown = false;
}
// 根据设施名称校验方向仅当 stnm 不为 null
if (StrUtil.isNotBlank(stnm)) {
String facilityName = stnm.toLowerCase().trim();
// 设施名称包含"上行"只允许上行或上行折返
if (facilityName.contains("上行") && !isUp && !isUpReturn) {
importRow.getWarnings().add("direction");
// 如果是字典编码返回对应的中文否则返回原始数据
return isDictCode ? getDirectionChinese(direction) : direction;
}
// 设施名称包含"下行"只允许下行或下行折返
if (facilityName.contains("下行") && !isDown && !isDownReturn) {
importRow.getWarnings().add("direction");
// 如果是字典编码返回对应的中文否则返回原始数据
return isDictCode ? getDirectionChinese(direction) : direction;
}
}
// 返回对应的字典编码
if (isUpReturn) {
return "2";
} else if (lowerName.contains("下行") && lowerName.contains("折返")) {
} else if (isDownReturn) {
return "3";
} else if (lowerName.contains("上行")) {
} else if (isUp) {
return "0";
} else if (lowerName.contains("下行")) {
} else if (isDown) {
return "1";
}
// 未匹配任何方向
importRow.getWarnings().add("direction");
return direction;
}
/**
* 根据字典编码返回对应的中文描述
*/
private String getDirectionChinese(String dictCode) {
if ("0".equals(dictCode)) {
return "上行";
} else if ("1".equals(dictCode)) {
return "下行";
} else if ("2".equals(dictCode)) {
return "上行折返";
} else if ("3".equals(dictCode)) {
return "下行折返";
}
return dictCode;
}
// public String resolveDirection(String stnm,String direction, FishImportResult.FishImportRow importRow) {
// if (direction == null) {
// return null;
// }
// String lowerName = direction.toLowerCase().trim();
// if (lowerName.contains("上行") && lowerName.contains("折返")) {
// return "2";
// } else if (lowerName.contains("下行") && lowerName.contains("折返")) {
// return "3";
// } else if (lowerName.contains("上行")) {
// return "0";
// } else if (lowerName.contains("下行")) {
// return "1";
// }
// importRow.getWarnings().add("direction");
// return direction;
// }
public String resolveIsfs(String value, FishImportResult.FishImportRow importRow) {
if (value == null) {
return null;

View File

@ -26,7 +26,7 @@ public class FishStatisticsServiceImpl implements IFishStatisticsService {
private FishStatisticsMapper fishStatisticsMapper;
@Override
public Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest) {
public Page<FishStatisticsVO> queryPage(DataSourceRequest dataSourceRequest, String tenantId) {
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
String basinNamesStr = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "basinCode");
@ -53,9 +53,9 @@ public class FishStatisticsServiceImpl implements IFishStatisticsService {
int endRow = startRow + pageSize;
List<FishStatisticsVO> records = fishStatisticsMapper.queryStatistics(
basinNamesStr, stationNamesStr, reportMonth, startRow, endRow);
basinNamesStr, stationNamesStr, reportMonth, tenantId, startRow, endRow);
int total = fishStatisticsMapper.countStatistics(basinNamesStr, stationNamesStr, reportMonth);
int total = fishStatisticsMapper.countStatistics(basinNamesStr, stationNamesStr, reportMonth, tenantId);
Page<FishStatisticsVO> page = new Page<>();
page.setRecords(records);

View File

@ -187,4 +187,10 @@ public class EngEqDataController {
public ResponseResult getEqdsKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(engEqDataService.getEqdsKendoListCust(dataSourceRequest));
}
@PostMapping("/GetKendoListCust")
@Operation(summary = "电站业务结果数据查询MS_ENG_T + V_MS_STBPRP_T")
public ResponseResult getMsEngKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(engEqDataService.getMsEngKendoList(dataSourceRequest));
}
}

View File

@ -2,26 +2,7 @@ package com.yfd.platform.qgc_eng.eq.service;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqBaseMsstbprptVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqBaseVmsstbprptVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqDayDataVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqDrtpDataVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqDayIntervalVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqdsVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqHourIntervalVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqIntervalVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqLimitQueryVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqLimitVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqMsstbprptVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqRuleVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngQecAlongVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqRateCountVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqVmsstbprptVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.QgcQecStaticVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.SdEqMonitorCountVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.StBaseInfo;
import com.yfd.platform.qgc_eng.eq.entity.vo.StcdInfoVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.WbsbVo;
import com.yfd.platform.qgc_eng.eq.entity.vo.*;
import java.util.List;
import java.util.Map;
@ -89,4 +70,10 @@ public interface EngEqDataService {
StcdInfoVo getStInfoByStcd(String stcd);
DataSourceResult<EngEqdsVo> getEqdsKendoListCust(DataSourceRequest dataSourceRequest);
/**
* 查询 MS_ENG_T 电站业务结果数据支持动态过滤排序分组
* <p>对应旧系统 EngEqController.getKendoListCust</p>
*/
DataSourceResult<EngEqDataVo> getMsEngKendoList(DataSourceRequest dataSourceRequest);
}

View File

@ -6337,4 +6337,338 @@ public class EngEqDataServiceImpl implements EngEqDataService {
.append(String.join(", ", placeholders))
.append(") ");
}
// ==================== MS_ENG_T 电站业务结果查询 ====================
@Override
public DataSourceResult<EngEqDataVo> getMsEngKendoList(DataSourceRequest dataSourceRequest) {
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
if (CollUtil.isEmpty(dataSourceRequest == null ? null : dataSourceRequest.getGroup())) {
return queryMsEngDetailList(dataSourceRequest, loadOptions);
}
return queryMsEngGroupList(dataSourceRequest, loadOptions);
}
private DataSourceResult<EngEqDataVo> queryMsEngDetailList(DataSourceRequest dataSourceRequest,
DataSourceLoadOptionsBase loadOptions) {
StringBuilder sql = new StringBuilder();
sql.append("SELECT ")
.append(buildMsEngDetailSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
.append(" ")
.append(buildMsEngViewSql())
.append(" WHERE NVL(MET.IS_DELETED, 0) = 0 ");
Map<String, Object> paramMap = new HashMap<>();
String filterSql = buildMsEngFilterCondition(dataSourceRequest == null ? null : dataSourceRequest.getFilter(), paramMap, new int[]{0});
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql).append(" ");
}
sql.append(buildMsEngDetailOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
List<EngEqDataVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, EngEqDataVo.class);
DataSourceResult<EngEqDataVo> result = new DataSourceResult<>();
result.setData(list);
result.setTotal(page != null ? page.getTotal() : list.size());
result.setAggregates(new HashMap<>());
return result;
}
private DataSourceResult<EngEqDataVo> queryMsEngGroupList(DataSourceRequest dataSourceRequest,
DataSourceLoadOptionsBase loadOptions) {
List<DataSourceRequest.GroupDescriptor> groups = dataSourceRequest.getGroup();
GroupingInfo[] groupInfos = loadOptions == null ? new GroupingInfo[0] : loadOptions.getGroup();
List<String> selectItems = new ArrayList<>();
for (DataSourceRequest.GroupDescriptor descriptor : groups) {
if (descriptor == null || StrUtil.isBlank(descriptor.getField())) {
continue;
}
String column = mapMsEngColumn(descriptor.getField());
if (StrUtil.isBlank(column)) {
continue;
}
selectItems.add(column + " AS " + descriptor.getField().toUpperCase());
selectItems.add("COUNT(*) AS COUNT_" + descriptor.getField().toUpperCase());
if (CollUtil.isNotEmpty(descriptor.getAggregates())) {
for (DataSourceRequest.AggregateDescriptor aggregate : descriptor.getAggregates()) {
String aggregateColumn = mapMsEngColumn(aggregate.getField());
if (StrUtil.isBlank(aggregateColumn) || StrUtil.isBlank(aggregate.getAggregate())) {
continue;
}
selectItems.add(buildMsEngAggregateSql(aggregate.getAggregate(), aggregateColumn, aggregate.getField()));
}
}
}
if (selectItems.isEmpty()) {
selectItems.add("MET.STCD AS STCD");
selectItems.add("COUNT(*) AS COUNT_STCD");
}
StringBuilder sql = new StringBuilder();
sql.append("SELECT ")
.append(String.join(", ", selectItems))
.append(" ")
.append(buildMsEngViewSql())
.append(" WHERE NVL(MET.IS_DELETED, 0) = 0 ");
Map<String, Object> paramMap = new HashMap<>();
String filterSql = buildMsEngFilterCondition(dataSourceRequest == null ? null : dataSourceRequest.getFilter(), paramMap, new int[]{0});
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql).append(" ");
}
List<String> groupByColumns = new ArrayList<>();
for (DataSourceRequest.GroupDescriptor descriptor : groups) {
if (descriptor == null || StrUtil.isBlank(descriptor.getField())) {
continue;
}
String column = mapMsEngColumn(descriptor.getField());
if (StrUtil.isNotBlank(column)) {
groupByColumns.add(column);
}
}
if (!groupByColumns.isEmpty()) {
sql.append(" GROUP BY ").append(String.join(", ", groupByColumns)).append(" ");
}
sql.append(buildMsEngGroupOrderBySql(groups));
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, sql.toString(), paramMap);
DataSourceResult<EngEqDataVo> result = new DataSourceResult<>();
if (dataSourceRequest.getGroupResultFlat() != null && dataSourceRequest.getGroupResultFlat()) {
result.setData((List<EngEqDataVo>) (List<?>) new GroupHelper().faltGroup(rows, Arrays.asList(groupInfos)));
} else {
result.setData((List<EngEqDataVo>) (List<?>) new GroupHelper().group(rows, Arrays.asList(groupInfos)));
}
result.setTotal(0L);
result.setAggregates(new HashMap<>());
return result;
}
/**
* MS_ENG_T + V_MS_STBPRP_T 联合查询的 FROM 子句
*/
private String buildMsEngViewSql() {
return "FROM MS_ENG_T MET " +
"LEFT JOIN MS_ENG_T MET1 ON MET1.STCD = MET.STCD " +
" AND MET1.TYPE = MET.TYPE " +
" AND ADD_MONTHS(MET1.TM, 12) = MET.TM " +
" AND NVL(MET1.IS_DELETED, 0) = 0 " +
"INNER JOIN V_MS_STBPRP_T MSB ON MSB.STCD = MET.STCD " +
" AND MSB.STTP_CODE = 'ENG' " +
" AND MSB.BLDSTT_CODE = 2 ";
}
private Map<String, String> msEngFieldColumns() {
Map<String, String> columns = new LinkedHashMap<>();
columns.put("id", "MET.ID AS id");
columns.put("stcd", "MET.STCD AS stcd");
columns.put("stnm", "MSB.STNM AS stnm");
columns.put("ennm", "MSB.ENNM AS ennm");
columns.put("tm", "MET.TM AS tm");
columns.put("qi", "MET.QI AS qi");
columns.put("qo", "MET.QO AS qo");
columns.put("qecLimit", "MET.QEC_LIMIT AS qecLimit");
columns.put("qec", "MET.QEC AS qec");
columns.put("mwrLimit", "MET.MWR_LIMIT AS mwrLimit");
columns.put("avqLimit", "MET.AVQ_LIMIT AS avqLimit");
columns.put("qecC", "MET.QEC_C AS qecC");
columns.put("mwrC", "MET.MWR_C AS mwrC");
columns.put("avqC", "MET.AVQ_C AS avqC");
columns.put("sfdb", "MET.QEC_SFDB AS sfdb");
columns.put("sfdbName", "CASE NVL(MET.QEC_SFDB, -1) WHEN 0 THEN '不达标' WHEN 1 THEN '达标' WHEN 2 THEN '无生态流量数据' WHEN 3 THEN '无生态流量限值要求' ELSE NULL END AS sfdbName");
columns.put("mwrSfdb", "MET.MWR_SFDB AS mwrSfdb");
columns.put("mwrSfdbName", "CASE NVL(MET.MWR_SFDB, -1) WHEN 0 THEN '不达标' WHEN 1 THEN '达标' WHEN 2 THEN '无生态流量数据' WHEN 3 THEN '无生态流量限值要求' ELSE NULL END AS mwrSfdbName");
columns.put("avqSfdb", "MET.AVQ_SFDB AS avqSfdb");
columns.put("avqSfdbName", "CASE NVL(MET.AVQ_SFDB, -1) WHEN 0 THEN '不达标' WHEN 1 THEN '达标' WHEN 2 THEN '无生态流量数据' WHEN 3 THEN '无生态流量限值要求' ELSE NULL END AS avqSfdbName");
columns.put("rz", "MET.RZ AS rz");
columns.put("dz", "MET.DDZ AS dz");
columns.put("baseName", "MSB.BASE_NAME AS baseName");
columns.put("rvcdName", "MSB.RVCD_NAME AS rvcdName");
columns.put("hbrvcdName", "MSB.HBRVCD_NAME AS hbrvcdName");
columns.put("addvcdName", "MSB.ADDVNM AS addvcdName");
columns.put("baseId", "MSB.BASE_ID AS baseId");
columns.put("hbrvcd", "MSB.HBRVCD AS hbrvcd");
columns.put("hycd", "MSB.HYCD AS hycd");
columns.put("rvcd", "MSB.RVCD AS rvcd");
columns.put("bldsttCcode", "MSB.BLDSTT_CODE AS bldsttCcode");
columns.put("beforeQec", "MET1.QEC AS beforeQec");
columns.put("baseStepSort", "NVL(MSB.BASESTEPSORT, 999999) AS baseStepSort");
columns.put("rvcdStepSort", "NVL(MSB.RVCDSTEPSORT, 999999) AS rvcdStepSort");
columns.put("rstcdStepSort", "NVL(MSB.RSTCDSTEPSORT, 999999) AS rstcdStepSort");
columns.put("siteStepSort", "NVL(MSB.SITESTEPSORT, 999999) AS siteStepSort");
return columns;
}
private String buildMsEngDetailSelectSql(List<String> selectFields) {
Map<String, String> columns = msEngFieldColumns();
List<String> selected = new ArrayList<>();
if (CollUtil.isEmpty(selectFields)) {
selected.addAll(columns.values());
} else {
for (String field : selectFields) {
String column = columns.get(field);
if (StrUtil.isNotBlank(column)) {
selected.add(column);
}
}
if (selected.isEmpty()) {
selected.addAll(columns.values());
}
}
return String.join(", ", selected);
}
private String buildMsEngFilterCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
if (filter == null) {
return "";
}
if (StrUtil.isNotBlank(filter.getField())) {
return buildMsEngLeafCondition(filter, paramMap, indexHolder);
}
if (CollUtil.isEmpty(filter.getFilters())) {
return "";
}
List<String> conditions = new ArrayList<>();
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
String childSql = buildMsEngFilterCondition(child, paramMap, indexHolder);
if (StrUtil.isNotBlank(childSql)) {
conditions.add("(" + childSql + ")");
}
}
if (conditions.isEmpty()) {
return "";
}
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
return String.join(logic, conditions);
}
private String buildMsEngLeafCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
String column = mapMsEngColumn(filter.getField());
if (StrUtil.isBlank(column)) {
return "";
}
return buildGenericCondition(column, filter, paramMap, indexHolder, isMsEngDateField(filter.getField()));
}
private String buildMsEngDetailOrderBySql(List<DataSourceRequest.SortDescriptor> sortList) {
if (CollUtil.isEmpty(sortList)) {
return " ORDER BY baseStepSort ASC, rvcdStepSort ASC, rstcdStepSort ASC, siteStepSort ASC, MET.TM DESC";
}
List<String> orders = new ArrayList<>();
for (DataSourceRequest.SortDescriptor sort : sortList) {
if (sort == null || StrUtil.isBlank(sort.getField())) {
continue;
}
String column = mapMsEngOrderColumn(sort.getField());
if (StrUtil.isBlank(column)) {
continue;
}
String dir = "desc".equalsIgnoreCase(sort.getDir()) || "des".equalsIgnoreCase(sort.getDir()) ? "DESC" : "ASC";
orders.add(column + " " + dir);
}
if (orders.isEmpty()) {
return " ORDER BY baseStepSort ASC, rvcdStepSort ASC, rstcdStepSort ASC, siteStepSort ASC, MET.TM DESC";
}
return " ORDER BY " + String.join(", ", orders);
}
private String buildMsEngGroupOrderBySql(List<DataSourceRequest.GroupDescriptor> groups) {
if (CollUtil.isEmpty(groups)) {
return "";
}
List<String> orders = new ArrayList<>();
for (DataSourceRequest.GroupDescriptor descriptor : groups) {
if (descriptor == null || StrUtil.isBlank(descriptor.getField())) {
continue;
}
String column = mapMsEngColumn(descriptor.getField());
if (StrUtil.isBlank(column)) {
continue;
}
String dir = "desc".equalsIgnoreCase(descriptor.getDir()) || "des".equalsIgnoreCase(descriptor.getDir()) ? "DESC" : "ASC";
orders.add(column + " " + dir);
}
return orders.isEmpty() ? "" : " ORDER BY " + String.join(", ", orders);
}
private String buildMsEngAggregateSql(String aggregate, String column, String field) {
if (StrUtil.isBlank(aggregate) || StrUtil.isBlank(column)) {
return null;
}
return switch (aggregate.toLowerCase()) {
case "sum" -> "SUM(" + column + ") AS SUM_" + field.toUpperCase();
case "avg" -> "AVG(" + column + ") AS AVG_" + field.toUpperCase();
case "min" -> "MIN(" + column + ") AS MIN_" + field.toUpperCase();
case "max" -> "MAX(" + column + ") AS MAX_" + field.toUpperCase();
default -> null;
};
}
private String mapMsEngColumn(String field) {
if (StrUtil.isBlank(field)) {
return null;
}
return switch (field) {
case "id" -> "MET.ID";
case "stcd" -> "MSB.STCD";
case "stnm" -> "MSB.STNM";
case "ennm" -> "MSB.ENNM";
case "tm" -> "MET.TM";
case "qi" -> "MET.QI";
case "qo" -> "MET.QO";
case "qecLimit" -> "MET.QEC_LIMIT";
case "qec" -> "MET.QEC";
case "mwrLimit" -> "MET.MWR_LIMIT";
case "avqLimit" -> "MET.AVQ_LIMIT";
case "qecC" -> "MET.QEC_C";
case "mwrC" -> "MET.MWR_C";
case "avqC" -> "MET.AVQ_C";
case "sfdb", "qecSfdb" -> "MET.QEC_SFDB";
case "mwrSfdb" -> "MET.MWR_SFDB";
case "avqSfdb" -> "MET.AVQ_SFDB";
case "rz" -> "MET.RZ";
case "dz" -> "MET.DDZ";
case "baseName" -> "MSB.BASE_NAME";
case "rvcdName" -> "MSB.RVCD_NAME";
case "hbrvcdName" -> "MSB.HBRVCD_NAME";
case "addvcdName" -> "MSB.ADDVNM";
case "baseId" -> "MSB.BASE_ID";
case "hbrvcd" -> "MSB.HBRVCD";
case "hycd" -> "MSB.HYCD";
case "rvcd" -> "MSB.RVCD";
case "bldsttCcode" -> "MSB.BLDSTT_CODE";
case "baseStepSort" -> "MSB.BASESTEPSORT";
case "rvcdStepSort" -> "MSB.RVCDSTEPSORT";
case "rstcdStepSort" -> "MSB.RSTCDSTEPSORT";
case "siteStepSort" -> "MSB.SITESTEPSORT";
default -> null;
};
}
private String mapMsEngOrderColumn(String field) {
if (StrUtil.isBlank(field)) {
return null;
}
return switch (field) {
case "id", "baseId", "hbrvcd", "hycd", "rvcd", "bldsttCcode",
"sfdbName", "mwrSfdb", "mwrSfdbName", "avqSfdb", "avqSfdbName",
"qecC", "mwrC", "avqC", "beforeQec",
"baseStepSort", "rvcdStepSort", "rstcdStepSort", "siteStepSort",
"stcd", "stnm", "ennm", "qi", "qo", "qec", "sfdb",
"rz", "dz", "qecLimit", "mwrLimit", "avqLimit", "baseName",
"rvcdName", "hbrvcdName", "addvcdName" -> field;
case "tm" -> "MET.TM";
default -> null;
};
}
private boolean isMsEngDateField(String field) {
return "tm".equalsIgnoreCase(field);
}
}

View File

@ -127,7 +127,31 @@ public class FishPassageController {
@GetMapping("/run/qgc/year/GetYearFpStatistics")
@Operation(summary = "全过程过鱼统计总数,根据基地分组")
public ResponseResult getYearFpStatic(@RequestParam("year") String year) {
return ResponseResult.successData(fpRunService.getYearFpStatic(year));
public ResponseResult getYearFpStatic(@RequestParam("year") String year,@RequestParam(value = "stcd",required = false) String stcd) {
return ResponseResult.successData(fpRunService.getYearFpStatic(year,stcd));
}
@PostMapping("/query/getTreeStcdList")
@Operation(summary = "过鱼数量获取有数据的测站树形下拉")
public ResponseResult getTreeStcdList(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fpRunService.getTreeStcdList(dataSourceRequest));
}
@PostMapping("/query/qgc/getOverfishTotal")
@Operation(summary = "环保部-过鱼总量-二级弹窗列表SD_FPSSRL_R + SD_FPSS_R 合并)")
public ResponseResult getQgcOverfishTotal(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fpRunService.processQgcOverfishTotalKendoList(dataSourceRequest));
}
@PostMapping("/fpssrlQdays/GetKendoListCust")
@Operation(summary = "过鱼设施自动数据日统计表SD_FPSSRLDAY_S")
public ResponseResult getQgcFpssrlQdaySKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fpRunService.processQgcFpssrlQdaySKendoList(dataSourceRequest));
}
@PostMapping("/fpssrlQdrtps/GetKendoListCust")
@Operation(summary = "过鱼设施自动数据周旬月年统计表SD_FPSSRLDRTP_S")
public ResponseResult getQgcFpssrlQdrtpSKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fpRunService.processQgcFpssrlQdrtpSKendoList(dataSourceRequest));
}
}

View File

@ -0,0 +1,83 @@
package com.yfd.platform.qgc_env.fp.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* 过鱼设施自动数据(带水温,流速)日统计表 VO
* </p>
* <p>对应新表 SD_FPSSRLDAY_S旧系统 SD_FPSSRLQDAY_S</p>
*/
@Data
@Schema(description = "过鱼设施自动数据日统计表")
public class FpFpssrlQdaySVo {
@Schema(description = "主键ID")
private String id;
@Schema(description = "过鱼设施编码")
private String stcd;
@Schema(description = "日期。精确到天")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date dt;
@Schema(description = "鱼类")
private String ftp;
@Schema(description = "自动过鱼设施过鱼数量")
private BigDecimal fcnt;
@Schema(description = "水温,单位:℃")
private BigDecimal temperature;
@Schema(description = "水位单位m")
private BigDecimal waterlevel;
@Schema(description = "流速单位m/s")
private BigDecimal speed;
@Schema(description = "流量单位m3/s")
private BigDecimal q;
@Schema(description = "溶氧单位mg/L")
private BigDecimal dox;
@Schema(description = "浊度单位NTU")
private BigDecimal tu;
@Schema(description = "鱼尺寸")
private String fsz;
@Schema(description = "鱼长度")
private BigDecimal length;
@Schema(description = "鱼宽度")
private BigDecimal width;
@Schema(description = "鱼速度")
private String fishspeed;
@Schema(description = "游向0=上行 1=下行")
private BigDecimal direction;
@Schema(description = "鱼位置")
private BigDecimal fishposition;
@Schema(description = "鱼截图主图片url")
private String firstimgurl;
@Schema(description = "鱼截图副图片url")
private String secondimgurl;
@Schema(description = "视频url")
private String videourl;
@Schema(description = "过鱼通道")
private String channelno;
}

View File

@ -0,0 +1,65 @@
package com.yfd.platform.qgc_env.fp.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* 过鱼设施自动数据(带水温,流速)周旬月年统计表 VO
* </p>
* <p>对应新表 SD_FPSSRLDRTP_S旧系统 SD_FPSSRLQDRTP_S</p>
*/
@Data
@Schema(description = "过鱼设施自动数据周旬月年统计表")
public class FpFpssrlQdrtpSVo {
@Schema(description = "主键ID")
private String id;
@Schema(description = "过鱼设施编码")
private String stcd;
@Schema(description = "数据时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date tm;
@Schema(description = "维度类型WEEK=周 TEN=旬 MON=月 QUA=季 YEAR=年")
private String drtp;
@Schema(description = "YYYY")
private Long year;
@Schema(description = "")
private Long month;
@Schema(description = "时段类型")
private Long dr;
@Schema(description = "鱼类")
private String ftp;
@Schema(description = "自动过鱼设施过鱼数量")
private Long fcnt;
@Schema(description = "水温,单位:℃")
private BigDecimal temperature;
@Schema(description = "水位单位m")
private BigDecimal waterlevel;
@Schema(description = "流速单位m/s")
private BigDecimal speed;
@Schema(description = "流量单位m3/s")
private BigDecimal q;
@Schema(description = "溶氧单位mg/L")
private BigDecimal dox;
@Schema(description = "浊度单位NTU")
private BigDecimal tu;
}

View File

@ -78,6 +78,12 @@ public class FpFpssrlQueryVo {
@Schema(description = "水温")
private String temperature;
private String waterlevel;
private String fishposition;
private String dox;
private String q;
private String tu;
@Schema(description = "流速")
private String speed;
@ -105,6 +111,11 @@ public class FpFpssrlQueryVo {
@Schema(description = "站点分类编码")
private String stCode;
@Schema(description = "是否鱼苗")
private Integer isfs;
@Schema(description = "站点分类名称")
private String stName;
private String remark;
}

View File

@ -0,0 +1,84 @@
package com.yfd.platform.qgc_env.fp.entity.vo;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 环保部-过鱼总量-二级弹窗列表 VO
* </p>
* <p>对应旧系统 FpssrlRQueryVo.getQgcOverfishTotal查询 SD_FPSSRL_R + SD_FPSS_R 合并数据</p>
*/
@Data
public class FpOverfishTotalVo {
/** 过鱼设施编码 */
private String stcd;
/** 设施名称 */
private String stnm;
/** 基地编码 */
private String baseId;
/** 基地名称 */
private String baseName;
/** 电站编码 */
private String rstcd;
/** 电站名称 */
private String ennm;
/** 时间 */
private Date tm;
/** 过鱼年份 */
private String yr;
/** 鱼类名称 */
private String ftp;
/** 鱼类编码 */
private String fishId;
/** 大小 */
private String fsz;
/** 鱼宽度 */
private String width;
/** 鱼速度 */
private String fishspeed;
/** 游向0=上行 1=下行 */
private String direction;
/** 水温 */
private String temperature;
/** 流速 */
private String speed;
/** 过鱼通道 */
private String channelno;
/** 数量 */
private String fcnt;
/** 图片URL */
private String firstimgurl;
/** 视频URL */
private String videourl;
/** 监测方式1=人工 2=自动 */
private Integer mway;
/** 人工过鱼 开始日期 */
private Date strdt;
/** 人工过鱼 结束日期 */
private Date enddt;
}

View File

@ -0,0 +1,24 @@
package com.yfd.platform.qgc_env.fp.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 过鱼设施测站树形分组 VO RSTCD 分组
*/
@Data
@Schema(description = "过鱼设施测站树形分组")
public class FpTreeStcdGroupVo {
@Schema(description = "电站编码")
private String rstcd;
@Schema(description = "电站名称")
private String ennm;
@Schema(description = "测站列表")
private List<FpTreeStcdVo> items = new ArrayList<>();
}

Some files were not shown because too many files have changed in this diff Show More