feat: 电站与布局组件配置管理

This commit is contained in:
tangwei 2026-07-23 16:05:39 +08:00
parent 001bccb626
commit c96d572ae6
17 changed files with 925 additions and 0 deletions

View File

@ -0,0 +1,82 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 平台产品化-业务组件基础表
*
* @author migration
*/
@Data
@TableName("MS_PPBCL_B")
public class MsPpbclB implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/** 编码 */
@TableField("CODE")
private String code;
/** 名称 */
@TableField("NAME")
private String name;
/** 适用方式normal=普通 eng_common=电站通用 */
@TableField("USETYPE")
private String usetype;
/** 备注 */
@TableField("REMARK")
private String remark;
/** 示例图base64 */
@TableField("EXAMPLEIMG")
private String exampleimg;
/** 前端配置数据 */
@TableField("DATA")
private String data;
/** 标签ID集合 */
@TableField("TAG_IDS")
private String tagIds;
// ---------- 非持久化字段 ----------
/** 标签名称集合 */
@TableField(exist = false)
private String tagNames;
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
private String recordUser;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
@TableField("MODIFY_USER")
private String modifyUser;
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
@TableField("IS_DELETED")
private Integer isDeleted;
@TableField("DELETE_USER")
private String deleteUser;
@TableField("DELETE_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deleteTime;
}

View File

@ -0,0 +1,72 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 平台产品化-页面布局基础表
*
* @author migration
*/
@Data
@TableName("MS_PPLAYOUT_B")
public class MsPplayoutB implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/** 布局类型page=页面布局 map=地图布局 */
@TableField("TYPE")
private String type;
/** 编码 */
@TableField("CODE")
private String code;
/** 名称 */
@TableField("NAME")
private String name;
/** 备注 */
@TableField("REMARK")
private String remark;
/** 示例图base64 */
@TableField("EXAMPLEIMG")
private String exampleimg;
/** 前端配置数据 */
@TableField("DATA")
private String data;
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
private String recordUser;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
@TableField("MODIFY_USER")
private String modifyUser;
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
@TableField("IS_DELETED")
private Integer isDeleted;
@TableField("DELETE_USER")
private String deleteUser;
@TableField("DELETE_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deleteTime;
}

View File

@ -0,0 +1,87 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 平台产品化-电站与布局组件配置表
*
* @author migration
*/
@Data
@TableName("MS_PSBMODULELB_B")
public class MsPsbmodulelbB implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/** 所属电站 */
@TableField("STCD")
private String stcd;
/** 布局 */
@TableField("LAYOUT_ID")
private String layoutId;
/** 布局各组件配置 */
@TableField("BCL_DATA")
private String bclData;
/** 角色ID */
@TableField("ROLE_ID")
private String roleId;
/** 是否布局 */
@TableField("IS_LAYOUT")
private Integer isLayout;
// ---------- 非持久化字段 ----------
/** 模板id */
@TableField(exist = false)
private String templateId;
/** 主控件标签配置 */
@TableField(exist = false)
private List<TagConfigVo> mainTagList;
/** 组件标签配置 */
@TableField(exist = false)
private List<TagConfigVo> ppbclTagList;
/** 有配置标签的组件集合 */
@TableField(exist = false)
private List<String> codeList;
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
private String recordUser;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
@TableField("MODIFY_USER")
private String modifyUser;
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
@TableField("IS_DELETED")
private Integer isDeleted;
@TableField("DELETE_USER")
private String deleteUser;
@TableField("DELETE_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deleteTime;
}

View File

@ -0,0 +1,72 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 页面标签配置表
*
* @author migration
*/
@Data
@TableName("MS_TAGCONFIG_B")
public class MsTagConfigB implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/** 菜单ID */
@TableField("MODULE_ID")
private String moduleId;
/** 模板ID */
@TableField("TEMPLATE_ID")
private String templateId;
/** 组件CODE */
@TableField("CODE")
private String code;
/** 标签ID */
@TableField("TAG_ID")
private String tagId;
/** 标签值 */
@TableField("TAG_VALUE")
private String tagValue;
/** 是否展示 0=否 1=是 */
@TableField("IS_SHOW")
private Integer isShow;
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
private String recordUser;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
@TableField("MODIFY_USER")
private String modifyUser;
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
@TableField("IS_DELETED")
private Integer isDeleted;
@TableField("DELETE_USER")
private String deleteUser;
@TableField("DELETE_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deleteTime;
}

View File

@ -0,0 +1,78 @@
package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 页面配置模板表
*
* @author migration
*/
@Data
@TableName("MS_TEMPLATE_B")
public class MsTemplateB implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/** 模板名称 */
@TableField("TEMPLATE_NAME")
private String templateName;
/** 模块ID */
@TableField("MODULE_ID")
private String moduleId;
/** 模板预览图片 */
@TableField("FID")
private String fid;
/** 页面配置ID */
@TableField("PAGE_ID")
private String pageId;
/** 是否是默认模板 0=否 1=是 */
@TableField("IS_DEFAULT")
private Integer isDefault;
// ---------- 非持久化字段 ----------
/** 模块类型 1=普通菜单模板 2=电站专题模板 */
@TableField(exist = false)
private Integer templateType;
/** 模块名称 */
@TableField(exist = false)
private String moduleName;
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
private String recordUser;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
@TableField("MODIFY_USER")
private String modifyUser;
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
@TableField("IS_DELETED")
private Integer isDeleted;
@TableField("DELETE_USER")
private String deleteUser;
@TableField("DELETE_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deleteTime;
}

View File

@ -0,0 +1,15 @@
package com.yfd.platform.qgc_base.domain;
import lombok.Data;
import java.io.Serializable;
/**
* 组件编码VO用于解析 BCL_DATA JSON
*/
@Data
public class PpbclCodeVo implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
}

View File

@ -0,0 +1,18 @@
package com.yfd.platform.qgc_base.domain;
import lombok.Data;
import java.io.Serializable;
/**
* 标签配置VO
*/
@Data
public class TagConfigVo implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
private String tagId;
private String tagValue;
private Integer isShow;
}

View File

@ -0,0 +1,9 @@
package com.yfd.platform.qgc_base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.qgc_base.domain.MsPpbclB;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MsPpbclBMapper extends BaseMapper<MsPpbclB> {
}

View File

@ -0,0 +1,9 @@
package com.yfd.platform.qgc_base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.qgc_base.domain.MsPplayoutB;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MsPplayoutBMapper extends BaseMapper<MsPplayoutB> {
}

View File

@ -0,0 +1,21 @@
package com.yfd.platform.qgc_base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.qgc_base.domain.MsPsbmodulelbB;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface MsPsbmodulelbBMapper extends BaseMapper<MsPsbmodulelbB> {
@Select("SELECT t1.* FROM MS_PSBMODULELB_B t1 " +
"INNER JOIN MS_PPLAYOUT_B t2 ON t1.LAYOUT_ID = t2.ID " +
"WHERE t1.STCD = #{stcd} AND t2.TYPE = #{layoutType}")
List<MsPsbmodulelbB> getPsbmoduleByMidAndLt(@Param("stcd") String stcd, @Param("layoutType") String layoutType);
@Select("${sql}")
List<MsPsbmodulelbB> selectBySql(@Param("sql") String sql);
}

View File

@ -0,0 +1,9 @@
package com.yfd.platform.qgc_base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.qgc_base.domain.MsTagConfigB;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MsTagConfigBMapper extends BaseMapper<MsTagConfigB> {
}

View File

@ -0,0 +1,9 @@
package com.yfd.platform.qgc_base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yfd.platform.qgc_base.domain.MsTemplateB;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MsTemplateBMapper extends BaseMapper<MsTemplateB> {
}

View File

@ -0,0 +1,33 @@
package com.yfd.platform.qgc_base.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.MsPsbmodulelbB;
import java.util.List;
/**
* 平台产品化-电站与布局组件配置表 Service 接口
*/
public interface IMsPsbmodulelbBService extends IService<MsPsbmodulelbB> {
/**
* 处理kendo列表含标签信息
*/
List<MsPsbmodulelbB> queryPageList(DataSourceRequest request);
/**
* 获取电站与布局组件配置列表
*/
List<MsPsbmodulelbB> getPsbmoduleByMidAndLt(String stcd, String layoutType);
/**
* 保存或更新数据
*/
boolean saveOrUpdateData(MsPsbmodulelbB entity);
/**
* 逻辑删除
*/
boolean deleteData(String id);
}

View File

@ -0,0 +1,242 @@
package com.yfd.platform.qgc_base.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.qgc_base.domain.*;
import com.yfd.platform.qgc_base.mapper.*;
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
import com.yfd.platform.qgc_base.service.IMsPsbmodulelbBService;
import com.yfd.platform.utils.SecurityUtils;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 平台产品化-电站与布局组件配置表 Service 实现类
*/
@Service
public class MsPsbmodulelbBServiceImpl extends ServiceImpl<MsPsbmodulelbBMapper, MsPsbmodulelbB> implements IMsPsbmodulelbBService {
private static final String TABLE_NAME = "MS_PSBMODULELB_B";
@Resource
private MsPsbmodulelbBMapper msPsbmodulelbBMapper;
@Resource
private MsTemplateBMapper msTemplateBMapper;
@Resource
private MsPpbclBMapper msPpbclBMapper;
@Resource
private MsTagConfigBMapper msTagConfigBMapper;
@Resource
private IMsOperationLogService msOperationLogService;
@Override
public List<MsPsbmodulelbB> queryPageList(DataSourceRequest request) {
String templateId = getFilterFieldValue(request, "templateId");
String moduleId = getFilterFieldValue(request, "stcd");
String ext = getFilterFieldValue(request, "ext");
StringBuilder sql = new StringBuilder();
if (StringUtils.isBlank(templateId) && StringUtils.isNotBlank(ext) && StringUtils.isNotBlank(moduleId)) {
// 查询模块下是否有标识为默认的模板
LambdaQueryWrapper<MsTemplateB> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(MsTemplateB::getIsDefault, 1);
lambdaQueryWrapper.eq(MsTemplateB::getIsDeleted, 0);
lambdaQueryWrapper.eq(MsTemplateB::getModuleId, moduleId);
MsTemplateB msTemplateB = msTemplateBMapper.selectOne(lambdaQueryWrapper);
if (msTemplateB != null && StringUtils.isNotBlank(msTemplateB.getPageId())) {
templateId = msTemplateB.getId();
}
}
if (StringUtils.isBlank(templateId)) {
// 查询系统默认配置
sql.append("SELECT ID, STCD, LAYOUT_ID, BCL_DATA FROM MS_PSBMODULELB_B WHERE IS_DELETED = 0 AND STCD = '")
.append(moduleId).append("'")
.append(" AND ID NOT IN (SELECT PAGE_ID FROM MS_TEMPLATE_B WHERE PAGE_ID IS NOT NULL AND MODULE_ID = '")
.append(moduleId).append("') ORDER BY RECORD_TIME DESC");
} else {
// 查询指定模板配置
sql.append("SELECT t2.ID, t2.STCD, t2.LAYOUT_ID, t2.BCL_DATA ")
.append("FROM MS_TEMPLATE_B t1 ")
.append("INNER JOIN MS_PSBMODULELB_B t2 ON t1.PAGE_ID = t2.ID AND t1.MODULE_ID = t2.STCD ")
.append("WHERE t1.ID = '").append(templateId).append("'")
.append(" AND t1.MODULE_ID = '").append(moduleId).append("'");
}
List<MsPsbmodulelbB> msPsbmodulelbBList = msPsbmodulelbBMapper.selectBySql(sql.toString());
// 获取电站配置的标签信息
if (!CollectionUtils.isEmpty(msPsbmodulelbBList)) {
MsPsbmodulelbB msPsbmodulelbB = msPsbmodulelbBList.get(0);
// 解析 BCL_DATA JSON 获取组件编码列表
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
List<PpbclCodeVo> ppbclCodeVos;
try {
ppbclCodeVos = mapper.readValue(msPsbmodulelbB.getBclData(), new TypeReference<List<PpbclCodeVo>>() {});
} catch (Exception e) {
throw new RuntimeException("解析 BCL_DATA 失败", e);
}
List<String> codeList = ppbclCodeVos.stream().map(PpbclCodeVo::getCode).collect(Collectors.toList());
// 查询组件是否有配置标签
LambdaQueryWrapper<MsPpbclB> ppbclBWrapper = new LambdaQueryWrapper<>();
ppbclBWrapper.select(MsPpbclB::getCode);
ppbclBWrapper.in(MsPpbclB::getCode, codeList);
ppbclBWrapper.isNotNull(MsPpbclB::getTagIds);
List<MsPpbclB> msPpbclBList = msPpbclBMapper.selectList(ppbclBWrapper);
if (!CollectionUtils.isEmpty(msPpbclBList)) {
List<String> codes = msPpbclBList.stream().map(MsPpbclB::getCode).collect(Collectors.toList());
msPsbmodulelbB.setCodeList(codes);
}
// 查询组件配置的标签值
LambdaQueryWrapper<MsTagConfigB> tagConfigWrapper = new LambdaQueryWrapper<>();
tagConfigWrapper.select(MsTagConfigB::getCode, MsTagConfigB::getTagId,
MsTagConfigB::getTagValue, MsTagConfigB::getIsShow);
tagConfigWrapper.eq(MsTagConfigB::getModuleId, moduleId);
if (StringUtils.isBlank(templateId)) {
tagConfigWrapper.isNull(MsTagConfigB::getTemplateId);
} else {
tagConfigWrapper.eq(MsTagConfigB::getTemplateId, templateId);
}
if (!codeList.isEmpty()) {
tagConfigWrapper.and(w -> {
w.in(MsTagConfigB::getCode, codeList);
w.or();
w.isNull(MsTagConfigB::getCode);
});
}
List<MsTagConfigB> msTagConfigBList = msTagConfigBMapper.selectList(tagConfigWrapper);
List<TagConfigVo> mainTagList = new ArrayList<>();
List<TagConfigVo> ppbclTagList = new ArrayList<>();
CopyOptions copyOptions = CopyOptions.create().setIgnoreCase(true).setIgnoreError(true);
for (MsTagConfigB msTagConfigB : msTagConfigBList) {
TagConfigVo tagConfigVo = BeanUtil.toBean(msTagConfigB, TagConfigVo.class, copyOptions);
if (StringUtils.isBlank(tagConfigVo.getCode())) {
mainTagList.add(tagConfigVo);
} else {
ppbclTagList.add(tagConfigVo);
}
}
msPsbmodulelbB.setMainTagList(mainTagList);
msPsbmodulelbB.setPpbclTagList(ppbclTagList);
}
return msPsbmodulelbBList;
}
@Override
public List<MsPsbmodulelbB> getPsbmoduleByMidAndLt(String stcd, String layoutType) {
return msPsbmodulelbBMapper.getPsbmoduleByMidAndLt(stcd, layoutType);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateData(MsPsbmodulelbB entity) {
// 如果包含图片则标记为布局
if (entity.getBclData() != null && entity.getBclData().contains("image/png")) {
entity.setIsLayout(1);
}
boolean result;
if (StringUtils.isNotBlank(entity.getId())) {
// 修改
MsPsbmodulelbB before = this.getById(entity.getId());
entity.setModifyUser(SecurityUtils.getCurrentUsername());
entity.setModifyTime(new Date());
result = this.updateById(entity);
if (result && before != null) {
msOperationLogService.recordModifyDetailLog(entity.getId(), TABLE_NAME, before, entity, "psbmodulelbb");
}
} else {
// 新增
entity.setRecordUser(SecurityUtils.getCurrentUsername());
entity.setRecordTime(new Date());
result = this.save(entity);
if (result) {
msOperationLogService.recordAddDetailLog(entity.getId(), TABLE_NAME, entity, "psbmodulelbb");
}
}
// 如果是新增且有关联模板ID更新模板的页面配置ID
if (result && StringUtils.isNotBlank(entity.getTemplateId())) {
MsTemplateB msTemplateB = new MsTemplateB();
msTemplateB.setId(entity.getTemplateId());
msTemplateB.setPageId(entity.getId());
msTemplateBMapper.updateById(msTemplateB);
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteData(String id) {
MsPsbmodulelbB entity = this.getById(id);
if (entity == null) {
return false;
}
LambdaUpdateWrapper<MsPsbmodulelbB> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(MsPsbmodulelbB::getId, id);
wrapper.set(MsPsbmodulelbB::getIsDeleted, 1);
wrapper.set(MsPsbmodulelbB::getDeleteUser, SecurityUtils.getCurrentUsername());
wrapper.set(MsPsbmodulelbB::getDeleteTime, new Date());
boolean result = this.update(wrapper);
if (result) {
msOperationLogService.recordDeleteDetailLog(id, TABLE_NAME, entity, "psbmodulelbb");
}
return result;
}
// ==================== 私有辅助方法 ====================
/**
* DataSourceRequest 过滤条件中提取指定字段的值
*/
private String getFilterFieldValue(DataSourceRequest request, String fieldName) {
if (request == null || request.getFilter() == null) {
return null;
}
return findFilterValue(request.getFilter(), fieldName);
}
private String findFilterValue(DataSourceRequest.FilterDescriptor filter, String fieldName) {
if (filter == null) {
return null;
}
if (fieldName.equals(filter.getField()) && filter.getValue() != null) {
return filter.getValue().toString();
}
if (filter.getFilters() != null) {
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
String value = findFilterValue(child, fieldName);
if (value != null) {
return value;
}
}
}
return null;
}
}

View File

@ -0,0 +1,104 @@
package com.yfd.platform.qgc_sys.psbmodulelbb.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.config.ResponseResult;
import com.yfd.platform.qgc_base.domain.MsPplayoutB;
import com.yfd.platform.qgc_base.domain.MsPsbmodulelbB;
import com.yfd.platform.qgc_base.mapper.MsPplayoutBMapper;
import com.yfd.platform.qgc_base.service.IMsPsbmodulelbBService;
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.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 平台产品化-电站与布局组件配置表控制器
*/
@Slf4j
@RestController
@RequestMapping("/sys/psbmodulelbb")
@Tag(name = "电站与布局组件配置管理")
public class MsPsbmodulelbBController {
@Resource
private IMsPsbmodulelbBService msPsbmodulelbBService;
@Resource
private MsPplayoutBMapper msPplayoutBMapper;
@PostMapping("/GetKendoListCust")
@Operation(summary = "条件过滤数据列表(含标签信息)")
public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
List<MsPsbmodulelbB> list = msPsbmodulelbBService.queryPageList(dataSourceRequest);
return ResponseResult.successData(list);
}
@GetMapping("/getPsbmoduleByMidAndLt")
@Operation(summary = "根据电站和布局类型获取配置列表")
public ResponseResult getPsbmoduleByMidAndLt(
@RequestParam("stcd") String stcd,
@RequestParam("layoutType") String layoutType) {
if (StringUtils.isBlank(stcd)) {
return ResponseResult.error("stcd 不能为空");
}
if (StringUtils.isBlank(layoutType)) {
return ResponseResult.error("layoutType 不能为空");
}
List<MsPsbmodulelbB> list = msPsbmodulelbBService.getPsbmoduleByMidAndLt(stcd, layoutType);
return ResponseResult.successData(list);
}
@PostMapping("/save")
@Operation(summary = "保存或更新电站与布局组件配置")
public ResponseResult save(@RequestBody MsPsbmodulelbB msPsbmodulelbB) {
// 校验必填字段
if (StringUtils.isBlank(msPsbmodulelbB.getStcd())
|| StringUtils.isBlank(msPsbmodulelbB.getLayoutId())
|| StringUtils.isBlank(msPsbmodulelbB.getBclData())) {
return ResponseResult.error("电站编码、布局ID、组件配置数据不能为空");
}
// 验证布局是否存在
LambdaQueryWrapper<MsPplayoutB> layoutWrapper = new LambdaQueryWrapper<>();
layoutWrapper.eq(MsPplayoutB::getCode, msPsbmodulelbB.getLayoutId());
layoutWrapper.eq(MsPplayoutB::getIsDeleted, 0);
MsPplayoutB pplayoutB = msPplayoutBMapper.selectOne(layoutWrapper);
if (pplayoutB == null) {
return ResponseResult.error("布局不存在");
}
// 修改时验证记录是否存在
if (StringUtils.isNotBlank(msPsbmodulelbB.getId())) {
MsPsbmodulelbB existing = msPsbmodulelbBService.getById(msPsbmodulelbB.getId());
if (existing == null) {
return ResponseResult.error("要修改的记录不存在");
}
}
boolean result = msPsbmodulelbBService.saveOrUpdateData(msPsbmodulelbB);
if (result) {
return ResponseResult.success();
} else {
return ResponseResult.error("数据保存失败");
}
}
@DeleteMapping("/{id}")
@Operation(summary = "逻辑删除电站与布局组件配置")
public ResponseResult delete(@PathVariable("id") String id) {
if (StringUtils.isBlank(id)) {
return ResponseResult.error("id 不能为空");
}
boolean result = msPsbmodulelbBService.deleteData(id);
if (result) {
return ResponseResult.success();
} else {
return ResponseResult.error("删除失败,记录不存在");
}
}
}

View File

@ -0,0 +1,51 @@
package com.yfd.platform.qgc_sys.psbmodulelbb.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 电站与布局组件配置VO
*/
@Data
public class MsPsbmodulelbBVo {
private String id;
/** 所属电站 */
private String stcd;
/** 布局ID */
private String layoutId;
/** 布局各组件配置 */
private String bclData;
/** 模板id */
private String templateId;
/** 是否布局 */
private Integer isLayout;
/** 主控件标签配置 */
private List<TagConfigVo> mainTagList;
/** 组件标签配置 */
private List<TagConfigVo> ppbclTagList;
/** 有配置标签的组件集合 */
private List<String> codeList;
/** 创建人 */
private String recordUser;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
/** 修改时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;
}

View File

@ -0,0 +1,14 @@
package com.yfd.platform.qgc_sys.psbmodulelbb.vo;
import lombok.Data;
/**
* 标签配置VO
*/
@Data
public class TagConfigVo {
private String code;
private String tagId;
private String tagValue;
private Integer isShow;
}