Lius
2024-11-04 d603739c0320f355cfc3152865918729fea790de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?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="org.jeecg.modules.mdc.mapper.EquipmentWorklineMapper">
 
    <select id="getMacingDataList" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
        select top 1 [${tableName}].* from [${tableName}] order by CollectTime  desc
    </select>
 
    <select id="findRunningData" resultType="java.lang.String">
        SELECT ProductCount FROM [${tableName}] WHERE ProductCount &lt;&gt; '' AND CollectTime BETWEEN #{ startTime } AND #{ endTime } GROUP BY ProductCount ORDER BY ProductCount
    </select>
 
    <select id="getEquipProgramNum" resultType="org.jeecg.modules.mdc.dto.EquipmentMachingDto">
        select Programnumber,CollectTime from [${tableName}] where CollectTime &gt; #{startTime} and CollectTime &lt;= #{endTime} and Programnumber is not null
    </select>
 
    <select id="findProductCountStartTime" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
        SELECT TOP 1 [${tableName}].* FROM [${tableName}] WHERE ProductCount = #{ productCount } AND CollectTime BETWEEN #{ startTime } AND #{ endTime } ORDER BY CollectTime ASC
    </select>
 
    <select id="findProductCountEndTime" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentDto">
        SELECT TOP 1 [${tableName}].* FROM [${tableName}] WHERE ProductCount = #{ productCount } AND CollectTime BETWEEN #{ startTime } AND #{ endTime } ORDER BY CollectTime DESC
    </select>
 
    <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>