electromagnetic-data/infrastructure/repository/target/classes/sqlmapper/IndicatorCardMapper.xml

198 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.electromagnetic.industry.software.data.manage.repository.dao.IndicatorCardMapper">
<resultMap id="BaseResultMap" type="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.IndicatorCard">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="indicator_card_no" jdbcType="VARCHAR" property="indicatorCardNo" />
<result column="indicator_card_name" jdbcType="VARCHAR" property="indicatorCardName" />
<result column="indicator_card_type" jdbcType="VARCHAR" property="indicatorCardType" />
<result column="dataservice_no" jdbcType="VARCHAR" property="dataserviceNo" />
<result column="dataservice_name" jdbcType="VARCHAR" property="dataserviceName" />
<result column="indicator_card_order" jdbcType="INTEGER" property="indicatorCardOrder" />
<result column="access_control" jdbcType="VARCHAR" property="accessControl" />
<result column="home_display" jdbcType="VARCHAR" property="homeDisplay" />
<result column="warning_flag" jdbcType="VARCHAR" property="warningFlag" />
<result column="template_nos" jdbcType="VARCHAR" property="templateNos" />
<result column="card_status" jdbcType="VARCHAR" property="cardStatus" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
</resultMap>
<resultMap id="IndicatorCardMap" type="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.IndicatorCardExtend">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="indicator_card_no" jdbcType="VARCHAR" property="indicatorCardNo" />
<result column="indicator_card_name" jdbcType="VARCHAR" property="indicatorCardName" />
<result column="indicator_card_type" jdbcType="VARCHAR" property="indicatorCardType" />
<result column="dataservice_no" jdbcType="VARCHAR" property="dataserviceNo" />
<result column="dataservice_name" jdbcType="VARCHAR" property="dataserviceName" />
<result column="indicator_card_order" jdbcType="INTEGER" property="indicatorCardOrder" />
<result column="access_control" jdbcType="VARCHAR" property="accessControl" />
<result column="home_display" jdbcType="VARCHAR" property="homeDisplay" />
<result column="warning_flag" jdbcType="VARCHAR" property="warningFlag" />
<result column="template_nos" jdbcType="VARCHAR" property="templateNos" />
<result column="home" jdbcType="VARCHAR" property="home" />
<result column="warning" jdbcType="VARCHAR" property="warning" />
<result column="card_status" jdbcType="VARCHAR" property="cardStatus" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
<result column="renew_type" jdbcType="VARCHAR" property="renewType" />
<result column="warning_indicator" jdbcType="VARCHAR" property="warningIndicator" />
</resultMap>
<sql id="Base_Column_List">
id, indicator_card_no, indicator_card_name, indicator_card_type, dataservice_no,
dataservice_name, indicator_card_order, access_control,home_display, warning_flag,
template_nos,card_status, creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified,
effect_flag
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dataplatform_wisdom_indicator_card
where indicator_card_no = #{indicatorCardNo,jdbcType=VARCHAR} and card_status='Enable' and effect_flag = 1
</select>
<select id="getIndicatorCardOrder"
parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.IndicatorCardParams"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dataplatform_wisdom_indicator_card
where effect_flag = 1
order by indicator_card_order desc
limit 1
</select>
<select id="getIndicatorCardListConfig" resultMap="IndicatorCardMap" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.IndicatorCardParams">
SELECT
card.id,
card.indicator_card_no,
card.indicator_card_name,
card.indicator_card_type,
card.dataservice_no,
card.dataservice_name,
card.indicator_card_order,
card.access_control,
card.home_display,
card.warning_flag,
card.template_nos,
card.card_status,
card.creator, card.creator_name, card.gmt_create, card.modifier,
card.modifier_name,card.gmt_modified,card.effect_flag,indictor.renew_type,indictor.warning_indicator,
( SELECT config_status FROM dataplatform_wisdom_user_resource_config WHERE resource_no = card.indicator_card_no AND config_type = 'indicatorCard' and member_code=#{userId,jdbcType=VARCHAR} limit 1) AS home,
( SELECT config_status FROM dataplatform_wisdom_indicator_org_config WHERE indicator_no = indictor.indicator_no AND config_type = 'warning' and org_code=#{orgCode,jdbcType=VARCHAR} limit 1) AS warning
FROM
dataplatform_wisdom_indicator_card card LEFT JOIN dataplatform_wisdom_user_resource_config config on config.resource_no=card.indicator_card_no
and config.member_code = #{userId,jdbcType=VARCHAR} and config.config_type = 'indicatorCard'
left JOIN dataplatform_wisdom_indicator indictor on indictor.indicator_card_no=card.indicator_card_no
and indictor.indicator_type='host'
<where>
card.effect_flag = 1
<if test="indicatorCardType!=null and indicatorCardType!='' and indicatorCardType!='ALL'">
and card.indicator_card_type='${indicatorCardType}'
</if>
<if test="accessControl!=null and accessControl!=''">
and card.access_control LIKE '%${accessControl}%'
</if>
<if test="indicatorName!=null and indicatorName!=''">
and indictor.indicator_name LIKE '%${indicatorName}%'
</if>
<if test="cardStatus!=null and cardStatus!=''">
and card.card_status='${cardStatus}'
</if>
<if test="homeType!=null and homeType!=''">
and ( config.resource_no is null or ( config.member_code=#{userId,jdbcType=VARCHAR} and config.config_status='display'))
</if>
</where>
GROUP BY card.id
order by card.indicator_card_order asc
</select>
<insert id="insert" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.IndicatorCard">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into dataplatform_wisdom_indicator_card (indicator_card_no, indicator_card_name,
indicator_card_type, dataservice_no, dataservice_name,
indicator_card_order, access_control,
home_display,warning_flag, template_nos, creator,
creator_name, gmt_create, modifier,
modifier_name, gmt_modified, effect_flag
)
values (#{indicatorCardNo,jdbcType=VARCHAR}, #{indicatorCardName,jdbcType=VARCHAR},
#{indicatorCardType,jdbcType=VARCHAR}, #{dataserviceNo,jdbcType=VARCHAR}, #{dataserviceName,jdbcType=VARCHAR},
#{indicatorCardOrder,jdbcType=VARCHAR}, #{accessControl,jdbcType=VARCHAR},
#{homeDisplay,jdbcType=VARCHAR},#{warningFlag,jdbcType=VARCHAR}, #{templateNos,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR},
#{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.IndicatorCard">
update dataplatform_wisdom_indicator_card
<set>
<if test="indicatorCardName != null">
indicator_card_name = #{indicatorCardName,jdbcType=VARCHAR},
</if>
<if test="indicatorCardType != null">
indicator_card_type = #{indicatorCardType,jdbcType=VARCHAR},
</if>
<if test="dataserviceNo != null">
dataservice_no = #{dataserviceNo,jdbcType=VARCHAR},
</if>
<if test="dataserviceName != null">
dataservice_name = #{dataserviceName,jdbcType=VARCHAR},
</if>
<if test="indicatorCardOrder != null">
indicator_card_order = #{indicatorCardOrder,jdbcType=INTEGER},
</if>
<if test="accessControl != null">
access_control = #{accessControl,jdbcType=VARCHAR},
</if>
<if test="homeDisplay != null">
home_display = #{homeDisplay,jdbcType=VARCHAR},
</if>
<if test="warningFlag != null">
warning_flag = #{warningFlag,jdbcType=VARCHAR},
</if>
<if test="templateNos != null">
template_nos = #{templateNos,jdbcType=VARCHAR},
</if>
<if test="modifier != null">
modifier = #{modifier,jdbcType=VARCHAR},
</if>
<if test="modifierName != null">
modifier_name = #{modifierName,jdbcType=VARCHAR},
</if>
gmt_modified = now()
</set>
where indicator_card_no = #{indicatorCardNo,jdbcType=VARCHAR} and effect_flag = 1
</update>
<update id="updateStatusOrEffect" parameterType="com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.IndicatorCard">
update dataplatform_wisdom_indicator_card
<set>
<if test="cardStatus != null">
card_status = #{cardStatus,jdbcType=VARCHAR},
</if>
<if test="effectFlag != null">
effect_flag = #{effectFlag,jdbcType=VARCHAR},
</if>
gmt_modified = now()
</set>
where indicator_card_no = #{indicatorCardNo,jdbcType=VARCHAR} and effect_flag = 1
</update>
<update id="updateIndicatorCardOrder" parameterType="java.util.List">
<foreach collection="list" separator=";" item="item">
update dataplatform_wisdom_indicator_card
set indicator_card_order = #{item.indicatorCardOrder,jdbcType=INTEGER}
where indicator_card_no = #{item.indicatorCardNo,jdbcType=VARCHAR} and effect_flag = 1
</foreach>
</update>
</mapper>