fix: 优化逻辑
This commit is contained in:
parent
fc0f84dc8d
commit
b203fe61eb
@ -1,19 +1,29 @@
|
|||||||
package com.yfd.platform.qgc_base.controller;
|
package com.yfd.platform.qgc_base.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
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.domain.SdFpssR;
|
||||||
import com.yfd.platform.qgc_base.service.ISdFpssRService;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 过鱼设施人工数据表 前端控制器
|
* 过鱼设施人工数据表 前端控制器
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/fpssR")
|
@RequestMapping("/data/fpssR")
|
||||||
@Tag(name = "过鱼数据管理")
|
@Tag(name = "过鱼数据管理")
|
||||||
@ -22,6 +32,12 @@ public class FpssRController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ISdFpssRService fpssRService;
|
private ISdFpssRService fpssRService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AttachmentUploadService attachmentUploadService;
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "分页查询过鱼数据列表")
|
@Operation(summary = "分页查询过鱼数据列表")
|
||||||
public ResponseResult queryPageList(
|
public ResponseResult queryPageList(
|
||||||
@ -44,37 +60,170 @@ public class FpssRController {
|
|||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@Operation(summary = "新增过鱼数据")
|
@Operation(summary = "新增过鱼数据")
|
||||||
public ResponseResult add(@RequestBody SdFpssR fpssR) {
|
public ResponseResult add(@RequestParam("data") String dataStr,
|
||||||
boolean result = fpssRService.save(fpssR);
|
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
|
||||||
return result ? ResponseResult.success("新增成功") : ResponseResult.error("新增失败");
|
@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")
|
@PostMapping("/update")
|
||||||
@Operation(summary = "修改过鱼数据")
|
@Operation(summary = "修改过鱼数据")
|
||||||
public ResponseResult update(@RequestBody SdFpssR fpssR) {
|
public ResponseResult update(@RequestParam("data") String dataStr,
|
||||||
boolean result = fpssRService.updateById(fpssR);
|
@RequestParam(value = "picFiles", required = false) List<MultipartFile> picFiles,
|
||||||
return result ? ResponseResult.success("修改成功") : ResponseResult.error("修改失败");
|
@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")
|
@PostMapping("/delete")
|
||||||
@Operation(summary = "删除过鱼数据")
|
@Operation(summary = "删除过鱼数据")
|
||||||
public ResponseResult delete(@RequestParam String id) {
|
public ResponseResult delete(@RequestBody SdEngInfoBHOperateRequest request) {
|
||||||
boolean result = fpssRService.removeById(id);
|
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("删除失败");
|
return result ? ResponseResult.success("删除成功") : ResponseResult.error("删除失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batchDelete")
|
// ==================== 附件处理辅助方法 ====================
|
||||||
@Operation(summary = "批量删除过鱼数据")
|
|
||||||
public ResponseResult batchDelete(@RequestBody java.util.List<String> ids) {
|
/**
|
||||||
if (ids == null || ids.isEmpty()) {
|
* 上传图片/视频附件并追加附件ID到 picpth/vdpth 字段(与已有ID以逗号拼接)
|
||||||
return ResponseResult.error("请选择要删除的数据");
|
*/
|
||||||
}
|
private void applyUploadedFiles(SdFpssR entity, List<MultipartFile> picFiles, List<MultipartFile> vdFiles) {
|
||||||
boolean result = true;
|
if (picFiles != null && !picFiles.isEmpty()) {
|
||||||
for (String id : ids) {
|
List<String> ids = attachmentUploadService.uploadMultipartFiles(picFiles);
|
||||||
if (!fpssRService.removeById(id)) {
|
if (!ids.isEmpty()) {
|
||||||
result = false;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package com.yfd.platform.qgc_base.domain;
|
package com.yfd.platform.qgc_base.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.yfd.platform.annotation.FieldChinese;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -24,121 +27,159 @@ public class SdFpssR implements Serializable {
|
|||||||
* 主键ID
|
* 主键ID
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.ASSIGN_UUID)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
|
@FieldChinese("主键ID")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过鱼设施编码
|
* 过鱼设施编码
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("过鱼设施编码")
|
||||||
private String stcd;
|
private String stcd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填报时间
|
* 填报时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("填报时间")
|
||||||
private Date tm;
|
private Date tm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 鱼种类
|
* 鱼种类
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("鱼种类")
|
||||||
private String ftp;
|
private String ftp;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String ftpName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 鱼类规格,单位:cm
|
* 鱼类规格,单位:cm
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("鱼类规格")
|
||||||
private String fsz;
|
private String fsz;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过鱼数量,单位:尾
|
* 过鱼数量,单位:尾
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("过鱼数量")
|
||||||
private Integer fcnt;
|
private Integer fcnt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平均体重,单位:g
|
* 平均体重,单位:g
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("平均体重")
|
||||||
private String fwet;
|
private String fwet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始日期
|
* 开始日期
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("开始日期")
|
||||||
private Date strdt;
|
private Date strdt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束日期
|
* 结束日期
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("结束日期")
|
||||||
private Date enddt;
|
private Date enddt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 游向:0=上行,1=下行,2=上行折返,3=下行折返
|
* 游向:0=上行,1=下行,2=上行折返,3=下行折返
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("游向")
|
||||||
private Integer direction;
|
private Integer direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当日运行次数
|
* 当日运行次数
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("当日运行次数")
|
||||||
private Integer rcnt;
|
private Integer rcnt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过鱼设施引用流量
|
* 过鱼设施引用流量
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("过鱼设施引用流量")
|
||||||
private BigDecimal fq;
|
private BigDecimal fq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过鱼图片文件路径
|
* 过鱼图片文件路径
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("过鱼图片文件路径")
|
||||||
private String picpth;
|
private String picpth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过鱼视频文件路径
|
* 过鱼视频文件路径
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("过鱼视频文件路径")
|
||||||
private String vdpth;
|
private String vdpth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 年份:数据时间,精确到年
|
* 年份:数据时间,精确到年
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("年份")
|
||||||
private Integer yr;
|
private Integer yr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主要月份
|
* 主要月份
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("主要月份")
|
||||||
private String mouth;
|
private String mouth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("创建人")
|
||||||
private String recordUser;
|
private String recordUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("创建时间")
|
||||||
private Date recordTime;
|
private Date recordTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新人
|
* 更新人
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("更新人")
|
||||||
private String modifyUser;
|
private String modifyUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("更新时间")
|
||||||
private Date modifyTime;
|
private Date modifyTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否已删除:0=未删除 1=已删除
|
* 是否已删除:0=未删除 1=已删除
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("是否已删除")
|
||||||
private Integer isDeleted;
|
private Integer isDeleted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除人
|
* 删除人
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("删除人")
|
||||||
private String deleteUser;
|
private String deleteUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除时间
|
* 删除时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@FieldChinese("删除时间")
|
||||||
private Date deleteTime;
|
private Date deleteTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否鱼苗(0否 1是)
|
* 是否鱼苗(0否 1是)
|
||||||
*/
|
*/
|
||||||
|
@FieldChinese("是否鱼苗")
|
||||||
private Integer isfs;
|
private Integer isfs;
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 水温:单位:℃
|
||||||
|
*/
|
||||||
|
@FieldChinese("水温")
|
||||||
|
private BigDecimal wtmp;
|
||||||
|
}
|
||||||
|
|||||||
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.yfd.platform.qgc_base.domain.SdFpssR;
|
import com.yfd.platform.qgc_base.domain.SdFpssR;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 过鱼设施人工数据表 服务类
|
* 过鱼设施人工数据表 服务类
|
||||||
@ -15,4 +18,19 @@ public interface ISdFpssRService extends IService<SdFpssR> {
|
|||||||
* 分页查询过鱼数据
|
* 分页查询过鱼数据
|
||||||
*/
|
*/
|
||||||
Page<SdFpssR> queryPageList(Page<SdFpssR> page, String stcd, Integer yr, String ftp);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@ -1,15 +1,27 @@
|
|||||||
package com.yfd.platform.qgc_base.service.impl;
|
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.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yfd.platform.qgc_base.domain.SdFpssR;
|
import com.yfd.platform.qgc_base.domain.SdFpssR;
|
||||||
import com.yfd.platform.qgc_base.mapper.SdFpssRMapper;
|
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.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.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -19,6 +31,30 @@ import java.util.Date;
|
|||||||
@Service
|
@Service
|
||||||
public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> implements ISdFpssRService {
|
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
|
@Override
|
||||||
public Page<SdFpssR> queryPageList(Page<SdFpssR> page, String stcd, Integer yr, String ftp) {
|
public Page<SdFpssR> queryPageList(Page<SdFpssR> page, String stcd, Integer yr, String ftp) {
|
||||||
LambdaQueryWrapper<SdFpssR> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SdFpssR> wrapper = new LambdaQueryWrapper<>();
|
||||||
@ -35,7 +71,9 @@ public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> impl
|
|||||||
|
|
||||||
wrapper.eq(SdFpssR::getIsDeleted, 0);
|
wrapper.eq(SdFpssR::getIsDeleted, 0);
|
||||||
wrapper.orderByDesc(SdFpssR::getRecordTime);
|
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
|
@Override
|
||||||
@ -51,14 +89,50 @@ public class SdFpssRServiceImpl extends ServiceImpl<SdFpssRMapper, SdFpssR> impl
|
|||||||
return super.updateById(entity);
|
return super.updateById(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public boolean removeById(Object id) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
// SdFpssR entity = getById(id);
|
public boolean add(SdFpssR entity, String source) {
|
||||||
// if (entity != null) {
|
if (entity == null || StrUtil.isBlank(entity.getStcd())) {
|
||||||
// entity.setIsDeleted(1);
|
throw new com.yfd.platform.common.exception.BizException("过鱼设施编码不能为空");
|
||||||
// entity.setDeleteTime(new Date());
|
}
|
||||||
// return updateById(entity);
|
boolean result = this.save(entity);
|
||||||
// }
|
if (result) {
|
||||||
// return false;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -982,7 +982,7 @@ public class FpBuildServiceImpl implements FpBuildService {
|
|||||||
columnMap.put("jbtxcs", "fp.JBTXCS");
|
columnMap.put("jbtxcs", "fp.JBTXCS");
|
||||||
columnMap.put("isUp", "fp.IS_UP");
|
columnMap.put("isUp", "fp.IS_UP");
|
||||||
columnMap.put("isDown", "fp.IS_DOWN");
|
columnMap.put("isDown", "fp.IS_DOWN");
|
||||||
columnMap.put("mway", "NULL");
|
columnMap.put("mway", "fp.MWAY");
|
||||||
columnMap.put("mwayName", "NULL");
|
columnMap.put("mwayName", "NULL");
|
||||||
columnMap.put("remark", "fp.REMARK");
|
columnMap.put("remark", "fp.REMARK");
|
||||||
columnMap.put("vlsr", "fp.VLSR");
|
columnMap.put("vlsr", "fp.VLSR");
|
||||||
|
|||||||
@ -53,6 +53,12 @@ public class VapConstructionController {
|
|||||||
return ResponseResult.successData(vpConstructionService.processBasinVplntKendoList(dataSourceRequest));
|
return ResponseResult.successData(vpConstructionService.processBasinVplntKendoList(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/bcount/GetKendoListCust")
|
||||||
|
@Operation(summary = "流域-珍稀植物园运行数据统计(SD_VP_R 按种类聚合)")
|
||||||
|
public ResponseResult getBasinCountKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(vpConstructionService.processBasinCountKendoList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/wva/GetKendoListCust")
|
@PostMapping("/wva/GetKendoListCust")
|
||||||
@Operation(summary = "野生动物监测情况")
|
@Operation(summary = "野生动物监测情况")
|
||||||
public ResponseResult getWvaKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getWvaKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.yfd.platform.qgc_env.vap.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流域-珍稀植物园运行数据统计 VO(对应旧系统 CountVplnt/BasinVplnt 统计)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "流域-珍稀植物园运行数据统计")
|
||||||
|
public class VpBasinCountVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "植物园编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "所属电站编码")
|
||||||
|
private String rstcd;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String ennm;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "保护种类ID")
|
||||||
|
private String plantId;
|
||||||
|
|
||||||
|
@Schema(description = "分类:1=花 2=草 3=树")
|
||||||
|
private BigDecimal unit;
|
||||||
|
|
||||||
|
@Schema(description = "保护种类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "年份")
|
||||||
|
private String year;
|
||||||
|
|
||||||
|
@Schema(description = "总数量")
|
||||||
|
private BigDecimal tecnt;
|
||||||
|
|
||||||
|
@Schema(description = "存活数量")
|
||||||
|
private BigDecimal surnum;
|
||||||
|
|
||||||
|
@Schema(description = "移栽规模")
|
||||||
|
private BigDecimal transplant;
|
||||||
|
|
||||||
|
@Schema(description = "种植要求")
|
||||||
|
private BigDecimal plantask;
|
||||||
|
|
||||||
|
@Schema(description = "存活率(%)")
|
||||||
|
private String rate;
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import com.yfd.platform.common.DataSourceRequest;
|
|||||||
import com.yfd.platform.common.DataSourceResult;
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.FhvapBuiltPointVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.FhvapBuiltPointVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.WvaPointVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.WvaPointVo;
|
||||||
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinCountVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinVplntVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinVplntVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpVarVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpVarVo;
|
||||||
@ -23,6 +24,8 @@ public interface VpConstructionService {
|
|||||||
|
|
||||||
DataSourceResult<VpBasinVplntVo> processBasinVplntKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<VpBasinVplntVo> processBasinVplntKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<VpBasinCountVo> processBasinCountKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<VpWvaRunVo> processWvaKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<VpWvaRunVo> processWvaKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<VpVacVo> processVacKendoList(DataSourceRequest dataSourceRequest);
|
DataSourceResult<VpVacVo> processVacKendoList(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
|||||||
import com.yfd.platform.common.PageInfo;
|
import com.yfd.platform.common.PageInfo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.FhvapBuiltPointVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.FhvapBuiltPointVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.WvaPointVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.WvaPointVo;
|
||||||
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinCountVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinVplntVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinVplntVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpConstructionSituationVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpConstructionSituationVo;
|
||||||
@ -185,6 +186,63 @@ public class VpConstructionServiceImpl implements VpConstructionService {
|
|||||||
return queryBasinVplntGroupList(dataSourceRequest, loadOptions);
|
return queryBasinVplntGroupList(dataSourceRequest, loadOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<VpBasinCountVo> processBasinCountKendoList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
String stcd = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stcd");
|
||||||
|
String baseId = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "baseId");
|
||||||
|
String rstcd = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "rstcd");
|
||||||
|
String tm = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "tm");
|
||||||
|
|
||||||
|
StringBuilder sqlB = new StringBuilder();
|
||||||
|
sqlB.append("SELECT r.STCD AS stcd, " +
|
||||||
|
"MAX(t.RSTCD) AS rstcd, " +
|
||||||
|
"MAX(t.ENNM) AS ennm, " +
|
||||||
|
"MAX(t.BASE_ID) AS baseId, " +
|
||||||
|
"MAX(t.BASE_NAME) AS baseName, " +
|
||||||
|
"r.PLANT_ID AS plantId, " +
|
||||||
|
"r.TYPE AS unit, " +
|
||||||
|
"b.NAME AS name, ");
|
||||||
|
if (StrUtil.isNotBlank(tm)) {
|
||||||
|
sqlB.append(" '").append(tm).append("' AS year, ");
|
||||||
|
}
|
||||||
|
sqlB.append("SUM(r.TECNT) AS tecnt, SUM(r.SURNUM) AS surnum, SUM(r.TRANSPLANT) AS transplant, SUM(r.PLANTASK) AS plantask, " +
|
||||||
|
"CASE WHEN SUM(r.TRANSPLANT) != 0 THEN TO_CHAR(ROUND(SUM(r.SURNUM) / SUM(r.TRANSPLANT) * 100, 2)) ELSE '-' END AS rate " +
|
||||||
|
"FROM SD_VP_R r " +
|
||||||
|
"INNER JOIN V_MS_STBPRP_T t ON r.STCD = t.STCD AND t.DATA_SOURCE = 'SD_VP_B_H' " +
|
||||||
|
"LEFT JOIN SD_VPBASIC_B b ON r.PLANT_ID = b.ID " +
|
||||||
|
"WHERE NVL(r.IS_DELETED, 0) = 0 AND NVL(t.IS_DELETED, 0) = 0 ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
if (StrUtil.isNotBlank(baseId)) {
|
||||||
|
sqlB.append(" AND t.BASE_ID = #{map.baseId} ");
|
||||||
|
paramMap.put("baseId", baseId);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(stcd)) {
|
||||||
|
sqlB.append(" AND t.STCD = #{map.stcd} ");
|
||||||
|
paramMap.put("stcd", stcd);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(rstcd)) {
|
||||||
|
sqlB.append(" AND t.RSTCD = #{map.rstcd} ");
|
||||||
|
paramMap.put("rstcd", rstcd);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(tm)) {
|
||||||
|
sqlB.append(" AND TO_CHAR(r.TM, 'yyyy') = #{map.tm} ");
|
||||||
|
paramMap.put("tm", tm);
|
||||||
|
}
|
||||||
|
sqlB.append("GROUP BY r.STCD, r.PLANT_ID, b.NAME, r.TYPE");
|
||||||
|
|
||||||
|
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
|
List<VpBasinCountVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
page, sqlB.toString(), paramMap, VpBasinCountVo.class
|
||||||
|
);
|
||||||
|
DataSourceResult<VpBasinCountVo> result = new DataSourceResult<>();
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private DataSourceResult<VpBasinVplntVo> queryBasinVplntDetailList(DataSourceRequest dataSourceRequest,
|
private DataSourceResult<VpBasinVplntVo> queryBasinVplntDetailList(DataSourceRequest dataSourceRequest,
|
||||||
DataSourceLoadOptionsBase loadOptions) {
|
DataSourceLoadOptionsBase loadOptions) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user