yangys
2025-04-11 120755e6874893d284fda5f617924d46960286c0
smart-man-boot/src/main/resources/com/qianwen/smartman/modules/mdc/mapper/SuperAlarmMapper.xml
@@ -44,55 +44,9 @@
    </select>
    <select id="selectListAlarm" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select *
        from iot_data.super_alarm
        where workstation_id = #{vo.workstationId}
        /*按照班次查询*/
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@SHIFT == vo.enums">
            and shift_index = #{vo.shiftIndex}
            and factory_date = #{queryTime}
        </if>
        /*按照日查询*/
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@DAY == vo.enums">
            and factory_date = #{queryTime}
        </if>
        /*按照月查询*/
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@MONTH == vo.enums">
            and factory_year = #{vo.year}
            and factory_month = #{vo.month}
        </if>
        /*按照周询*/
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@WEEK == vo.enums">
            and factory_year = #{vo.year}
            and factory_week = #{vo.week}
        </if>
    </select>
    <select id="queryAlarm" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select *
        from iot_data.super_alarm
        where workstation_id = #{vo.workstationId}
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@SHIFT == vo.enums">
            and shift_index = #{vo.shiftIndex}
            and factory_date = #{queryTime}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@DAY == vo.enums">
            and factory_date = #{queryTime}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@MONTH == vo.enums">
            and factory_year = #{vo.year}
            and factory_month = #{vo.month}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@WEEK == vo.enums">
            and factory_year = #{vo.year}
            and factory_week = #{vo.week}
        </if>
        order by ts desc
        <if test="query != null">
            limit ${(query.current - 1) * query.size}, ${query.size}
        </if>
    </select>
    <select id="selectAllAlarm" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select *
@@ -122,13 +76,7 @@
        order by ts desc
    </select>
    <select id="selectListAlarmByShift" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select *
        from iot_data.super_alarm
        where workstation_id = #{workstationId}
          and factory_date <![CDATA[>=]]> #{startDate}
          and factory_date <![CDATA[<=]]> #{endDate}
    </select>
    <select id="alarmReportByTime" resultType="com.qianwen.smartman.modules.report.vo.WorkstaionAlarmByTimeReportVO">
        select
@@ -262,20 +210,81 @@
   
   <!-- 原始limit limit #{start}, #{end} ,实际上end应该是pageSize-->
    <select id="alarmByWorkstation" resultType="com.qianwen.smartman.modules.mdc.vo.AlarmAnalysisWorkstationVO">
        select code    as alarmCode,
        select code as alarmCode,
               message as alarmMsg
        from root.f2.alarm_*
        where workstation_id = #{workstationId}
        order by time desc
        from root.f2.alarm_${workstationId} order by time desc
            limit #{end} offset #{start}
          align by device
    </select>
    
    <select id="alarmByWorkstationTotal" resultType="java.lang.Integer">
        select count(workstation_id)
        select count(workstation_id) from root.f2.alarm_${workstationId}
    </select>
    <!-- , -->
    <sql id="alarmColumns">
        code,message,level,workstation_id as workstationId,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
    </sql>
    <select id="selectListAlarm" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select <include refid="alarmColumns"/>
        from root.f2.alarm_*
        where workstation_id = #{vo.workstationId}
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@SHIFT == vo.enums">
            and shift_index = #{vo.shiftIndex}
            and factory_date = #{factoryDate}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@DAY == vo.enums">
            and factory_date = #{factoryDate}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@MONTH == vo.enums">
            and factory_year = #{vo.year}
            and factory_month = #{vo.month}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@WEEK == vo.enums">
            and factory_year = #{vo.year}
            and factory_week = #{vo.week}
        </if>
         align by device
    </select>
    <select id="queryAlarm" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select <include refid="alarmColumns"/>
        from root.f2.alarm_*
        where workstation_id = #{vo.workstationId}
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@SHIFT == vo.enums">
            and shift_index = #{vo.shiftIndex}
            and factory_date = #{factoryDate}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@DAY == vo.enums">
            and factory_date = #{factoryDate}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@MONTH == vo.enums">
            and factory_year = #{vo.year}
            and factory_month = #{vo.month}
        </if>
        <if test="@com.qianwen.smartman.modules.mdc.enums.StatisticalMethodEnum@WEEK == vo.enums">
            and factory_year = #{vo.year}
            and factory_week = #{vo.week}
        </if>
        order by time desc
        <if test="query != null">
            limit ${query.size} offset ${(query.current - 1) * query.size}
        </if>
         align by device
    </select>
    <select id="selectListAlarmByShift" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAlarm">
        select <include refid="alarmColumns"/>
        from root.f2.alarm_*
        where workstation_id = #{workstationId}
          and factory_date <![CDATA[>=]]> #{startFactoryDate}
          and factory_date <![CDATA[<=]]> #{endFactoryDate}
          align by device
    </select>
</mapper>