fix: 优化逻辑

This commit is contained in:
tangwei 2026-07-27 18:26:54 +08:00
parent 8e8c5dc2f4
commit cc3d280dda
4 changed files with 29 additions and 5 deletions

View File

@ -2,6 +2,8 @@ package com.yfd.platform.qgc_base.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yfd.platform.annotation.UserIdField;
import com.yfd.platform.annotation.UserNameField;
import lombok.Data;
import java.io.Serializable;
@ -64,8 +66,13 @@ public class MsWarnRuleB implements Serializable {
// ---------- 审计字段 ----------
@TableField("RECORD_USER")
@UserIdField
private String recordUser;
@TableField(exist = false)
@UserNameField
private String recordUserName;
@TableField("RECORD_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;

View File

@ -38,7 +38,7 @@ public interface MsWarnRuleBMapper extends BaseMapper<MsWarnRuleB> {
@Select("SELECT t1.ID, RULE_NAME AS ruleName, RULE_CODE AS ruleCode, t2.LVL AS lvl " +
"FROM MS_WARN_RULE_B t1 INNER JOIN MS_WARN_RULE_DETAIL_B t2 ON t1.ID = t2.RULE_ID " +
"WHERE 1=1 AND t1.STCD = #{stcd} " +
"WHERE 1=1 AND (t1.RULE_CODE ='common' OR (t1.RULE_CODE ='custom' AND t1.STCD=#{stcd})) " +
"AND t1.RULE_TYPE = #{ruleType} AND t1.IS_DELETED = 0 AND t2.IS_DELETED = 0 " +
"GROUP BY t1.ID, RULE_NAME, RULE_CODE, lvl")
List<WarnRuleVo> getRuleListByStcd(@Param("stcd") String stcd, @Param("ruleType") String ruleType);
@ -46,7 +46,7 @@ public interface MsWarnRuleBMapper extends BaseMapper<MsWarnRuleB> {
@Update("UPDATE MS_WARN_RULE_B SET STCD = #{stcd} WHERE ID = #{id}")
void updateStcd(@Param("stcd") String stcd, @Param("id") String id);
@Select("SELECT t2.STTP_NAME FROM V_MS_STBPRP_T t1 INNER JOIN SD_STTP_B t2 ON t1.STTP = t2.ID WHERE t1.STCD = #{stcd}")
@Select("SELECT t2.STTP_NAME FROM V_MS_STBPRP_T t1 INNER JOIN SD_STTP_B t2 ON t1.STTP = t2.STTP_CODE WHERE t1.STCD = #{stcd}")
String getSttpCodeNameByStcd(@Param("stcd") String stcd);
@Select("SELECT COUNT(t1.ID) FROM MS_WARN_RULE_B t1 INNER JOIN MS_WARN_RULE_DETAIL_B t2 ON t1.ID = t2.RULE_ID " +

View File

@ -11,6 +11,7 @@ import com.yfd.platform.common.DataSourceLoadOptionsBase;
import com.yfd.platform.common.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
import com.yfd.platform.common.utils.UserNameFillHelper;
import com.yfd.platform.qgc_base.domain.MsWarnRuleB;
import com.yfd.platform.qgc_base.domain.MsWarnRuleDetailB;
import com.yfd.platform.qgc_base.domain.MsWarnRuleStbprpB;
@ -70,9 +71,13 @@ public class MsWarnRuleBServiceImpl extends ServiceImpl<MsWarnRuleBMapper, MsWar
@Resource
private MsWarnRuleStbprpBMapper msWarnRuleStbprpBMapper;
@Resource
private UserNameFillHelper userNameFillHelper;
@Override
public Page<MsWarnRuleB> queryPageList(DataSourceRequest request) {
Page<MsWarnRuleB> page = DataSourceRequestUtil.executeQuery(request, MsWarnRuleB.class, this);
userNameFillHelper.fillUserNames(page.getRecords());
dictCodeToNameConverter.convertCodeToName(page, CODE_TO_NAME_META_LIST);
return page;
}
@ -372,10 +377,10 @@ public class MsWarnRuleBServiceImpl extends ServiceImpl<MsWarnRuleBMapper, MsWar
public DataSourceResult<MsWarnRuleBVo> getRuleBindList(DataSourceRequest request) {
DataSourceResult<MsWarnRuleBVo> dataSourceResult = new DataSourceResult<>();
StringBuilder sql = new StringBuilder();
sql.append("SELECT id AS bindId, STCD, STNM, STTP_CODE AS sttpCode, RULE_NAME AS ruleName, ")
sql.append("SELECT id AS bindId, STCD,RULE_ID, STNM, STTP_CODE AS sttpCode, RULE_NAME AS ruleName, ")
.append("RULE_TYPE AS ruleType, recordUser, MODIFY_TIME AS modifyTime, isShow, RULE_CODE AS ruleCode ")
.append("FROM (\n")
.append("SELECT t1.ID, t1.STCD, t3.STNM, t3.STTP_CODE, t2.RULE_NAME, t2.RULE_TYPE, ")
.append("SELECT t1.ID,t2.ID RULE_ID, t1.STCD, t3.STNM, t3.STTP_CODE, t2.RULE_NAME, t2.RULE_TYPE, ")
.append("t2.RECORD_USER AS recordUser, t2.MODIFY_TIME, t2.DESCRIPTION, t2.IS_SHOW AS isShow, t2.RULE_CODE ")
.append("FROM MS_WARN_RULE_STBPRP_B t1\n")
.append("INNER JOIN MS_WARN_RULE_B t2 ON t1.RULE_ID = t2.ID\n")
@ -393,6 +398,7 @@ public class MsWarnRuleBServiceImpl extends ServiceImpl<MsWarnRuleBMapper, MsWar
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
List<MsWarnRuleBVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), params, MsWarnRuleBVo.class);
dictCodeToNameConverter.convertCodeToName(list, CODE_TO_NAME_META_LIST);
userNameFillHelper.fillUserNames(list);
dataSourceResult.setData(list);
dataSourceResult.setTotal(page == null ? list.size() : page.getTotal());
return dataSourceResult;

View File

@ -1,6 +1,9 @@
package com.yfd.platform.qgc_sys.warnRule.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yfd.platform.annotation.UserIdField;
import com.yfd.platform.annotation.UserNameField;
import lombok.Data;
import java.util.Date;
@ -18,6 +21,8 @@ public class MsWarnRuleBVo {
/** 设施与规则绑定id */
private String bindId;
/** 告警规则名称 */
private String ruleId;
/** 告警规则名称 */
private String ruleName;
@ -58,11 +63,17 @@ public class MsWarnRuleBVo {
private List<MsWarnRuleDetailVo> detail;
/** 创建人 */
@UserIdField
private String recordUser;
/** 创建人名称 */
/** 创建人 */
@UserNameField
@TableField(exist = false)
private String recordUserName;
// /** 创建人名称 */
// private String recordUserName;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date modifyTime;