Lius
2024-11-04 d603739c0320f355cfc3152865918729fea790de
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/EquipmentWorklineMapper.xml
@@ -25,4 +25,80 @@
    <select id="getDataList" resultType="java.util.Map">
        select top 1 [${tableName}].* from [${tableName}] order by CollectTime  desc
    </select>
    <select id="getMinDate" resultType="java.util.Date">
        SELECT TOP 1 CollectTime from [${tableName}] ORDER BY CollectTime ASC
    </select>
    <select id="getMaxElectric" resultType="org.jeecg.modules.mdc.dto.CurrentElectricDto">
        SELECT TOP 1
        <if test="axisType != null and axisType != '' and axisType == 1">
            ABS( actualCurrentX ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 2">
            ABS( actualCurrentY ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 3">
            ABS( actualCurrentZ ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 4">
            ABS( actualCurrentA ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        <if test="axisType != null and axisType != '' and axisType == 5">
            ABS( actualCurrentB ) currentValue,
            EquipmentID,
            CollectTime
        </if>
        FROM
            [${tableName}]
        WHERE
        <if test="axisType != null and axisType != '' and axisType == 1">
            ABS( actualCurrentX ) = ( SELECT MAX ( ABS( actualCurrentX ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 2">
            ABS( actualCurrentY ) = ( SELECT MAX ( ABS( actualCurrentY ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 3">
            ABS( actualCurrentZ ) = ( SELECT MAX ( ABS( actualCurrentZ ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 4">
            ABS( actualCurrentA ) = ( SELECT MAX ( ABS( actualCurrentA ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
        <if test="axisType != null and axisType != '' and axisType == 5">
            ABS( actualCurrentB ) = ( SELECT MAX ( ABS( actualCurrentB ) ) currentValue FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
        </if>
    </select>
    <select id="getNearTimeSpindleLoad" resultType="org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto">
        SELECT TOP 1
            CollectTime collectTime,
            spindleload,
            spindlespeed
        FROM
            [${tableName}]
        WHERE
            CollectTime BETWEEN #{startDate} AND #{endDate}
        ORDER BY
            ABS( DATEDIFF( SECOND, CollectTime, #{nearDate} ) )
    </select>
    <select id="getMaxSpindleLoad" resultType="org.jeecg.modules.mdc.dto.EquipmentMachiningHistoryDto">
        SELECT TOP 1
            CollectTime collectTime,
            EquipmentID equipmentID,
            spindleload spindleLoad,
            spindlespeed spindleSpeed
        FROM
            [${tableName}]
        WHERE
            ABS( spindleload ) = ( SELECT MAX ( ABS( spindleload ) ) spindleload FROM [${tableName}] WHERE CollectTime BETWEEN #{startDate} AND #{endDate} )
    </select>
</mapper>