yangys
2024-10-30 25db770e621f1259b8d5b7fd514207f7481c2d0f
smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAggregateOutputMapper.xml
@@ -2,62 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qianwen.smartman.modules.mdc.mapper.SuperAggregateOutputMapper">
    <select id="getOutputDataByNaturalDate" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select ts as startTime,
        pre_ts as endTime,
        output,
        cur_output as curOutput,
        pre_output as preOutput,
        calendar_code as calendarCode,
        factory_year as factoryYear,
        factory_month as factoryMonth,
        factory_week as factoryWeek,
        factory_date as factoryDate,
        shift_index as shiftIndex,
        shift_time_type as shiftTimeType,
        program,
        product_code as productCode,
        product_name as productName,
        workstation_id as workstationId
        from iot_data.super_aggregate_output
        where ts <![CDATA[>=]]> #{startDate} and ts <![CDATA[<]]> #{endDate}
            AND output <![CDATA[>=]]> 0
        <if test="workstationIds != null and workstationIds.size() > 0">
            AND workstation_id IN
            <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="getOutputDataByFactoryDate"
            resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select ts as startTime,
        pre_ts as endTime,
        output,
        cur_output as curOutput,
        pre_output as preOutput,
        calendar_code as calendarCode,
        factory_year as factoryYear,
        factory_month as factoryMonth,
        factory_week as factoryWeek,
        factory_date as factoryDate,
        shift_index as shiftIndex,
        shift_time_type as shiftTimeType,
        program,
        product_code as productCode,
        product_name as productName,
        workstation_id as workstationId
        from iot_data.super_aggregate_output
        where output <![CDATA[>=]]> 0
        and factory_date <![CDATA[>=]]> #{startDate} and factory_date <![CDATA[<=]]> #{endDate}
        <if test="workstationIds != null and workstationIds.size() > 0">
            AND workstation_id IN
            <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="getOutputDataByWorkstationAndFactoryDate"
            resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
@@ -400,6 +347,54 @@
        and output > 0
        and factory_month = #{month}
    </select>
    <!-- sql修改开始 -->
    <!-- 列名中,program和已下的实际上都没有 -->
    <sql id="aggregateOutputColumns">
        pre_time as preTime,
        output as output,
        cur_output as curOutput,
        pre_output as preOutput,
        calendar_code as calendarCode,
        factory_year as factoryYear,
        factory_month as factoryMonth,
        factory_week as factoryWeek,
        factory_date as factoryDate,
        shift_index as shiftIndex,
        shift_time_type as shiftTimeType,
        program,
        product_code as productCode,
        product_name as productName,
        workstation_id as workstationId
    </sql>
   <select id="getOutputDataByFactoryDate"
            resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select <include refid="aggregateOutputColumns"/>
        from root.f2.aggregate_output_*
        where output <![CDATA[>=]]> 0
        and factory_date <![CDATA[>=]]> #{startFatoryDate} and factory_date <![CDATA[<=]]> #{endFatoryDate}
        <if test="workstationIds != null and workstationIds.size() > 0">
            AND workstation_id IN
            <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
         align by device
    </select>
    <select id="getOutputDataByNaturalDate" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select <include refid="aggregateOutputColumns"/>
        from root.f2.aggregate_output_*
        where time <![CDATA[>=]]> #{startDate} and time <![CDATA[<]]> #{endDate}
            AND output <![CDATA[>=]]> 0
        <if test="workstationIds != null and workstationIds.size() > 0">
            AND workstation_id IN
            <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
         align by device
    </select>
</mapper>