潘志宝
2024-11-21 d338b50afd6504a9676f0a26b3ecbcc844483e7c
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml
@@ -1,74 +1,28 @@
<?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.iailab.module.data.ind.dao.IndItemDao">
<mapper namespace="com.iailab.module.data.ind.item.dao.IndItemDao">
    <select id="getItemAtom" resultType="com.iailab.module.data.ind.dto.IndItemDTO">
      SELECT
        t1.item_no,
        t1.item_name,
        t1.item_type,
        t1.coefficient,
        t1.precision,
        t1.time_range,
        t1.time_granularity,
        t2.data_source,
        t2.query_sql
        FROM t_ind_item t1
        LEFT JOIN t_ind_item_atom t2 ON t2.item_id = t1.id
    <select id="getItemList" resultType="com.iailab.module.data.ind.item.vo.IndItemRespVO">
        select
        t1.*,
        t2.item_id as atomItemId
        from t_ind_item t1
        left join t_ind_item_atom t2 on t2.item_id = t1.id
        <where>
            t1.item_type =  #{itemType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            <if test="params.itemNo != null and params.itemNo != ''">
                and t1.item_no like concat('%', #{params.itemNo}, '%')
            </if>
            <if test="timeGranularity != null and timeGranularity != ''">
                AND t1.time_granularity = #{timeGranularity}
            <if test="params.itemName != null and params.itemName != ''">
                and t1.item_name like concat('%', #{params.itemName}, '%')
            </if>
            <if test="itemNo != null and itemNo != ''">
                AND t1.item_no = #{itemNo}
            <if test="params.itemType != null and params.itemType != ''">
                and t1.item_type = #{params.itemType}
            </if>
            <if test="itemNos != null">
                AND t1.item_no in
                <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            <if test="params.itemCategory != null and params.itemCategory != ''">
                and t1.item_category = #{params.itemCategory}
            </if>
        </where>
    </select>
    <select id="getItemCal" resultType="com.iailab.module.data.ind.dto.IndItemDTO">
        SELECT
        t1.item_no,
        t1.item_name,
        t1.item_type,
        t1.coefficient,
        t1.precision,
        t1.time_range,
        t1.time_granularity,
        t2.expression
        FROM t_ind_item t1
        LEFT JOIN t_ind_item_cal t2 ON t2.item_id = t1.id
        <where>
            t1.item_type =  #{itemType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            </if>
            <if test="timeGranularity != null and timeGranularity != ''">
                AND t1.time_granularity = #{timeGranularity}
            </if>
            <if test="itemNo != null and itemNo != ''">
                AND t1.item_no = #{itemNo}
            </if>
            <if test="itemNos != null">
                AND t1.item_no in
                <foreach collection="itemNos" item="item" index="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
</mapper>