zhuo
2025-02-28 217e39bec2ae2a861c4619d277ab0bc823cf85d4
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
<?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.ruoyi.require.mapper.FePowerStableMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.require.pojo.FePowerStable">
        <id column="power_stable_id" property="powerStableId" />
        <result column="test_location" property="testLocation" />
        <result column="test_date" property="testDate" />
        <result column="device_id" property="deviceId" />
        <result column="conclusion" property="conclusion" />
        <result column="tester_id" property="testerId" />
        <result column="checker_id" property="checkerId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>
 
    <select id="getLaboratoryFacilityPowerStablePage" resultType="com.ruoyi.require.dto.FePowerStableDto">
        SELECT cfps.*, u1.name checker_user, u2.name tester_user, dv.device_name, dv.management_number
        FROM cnas_fe_power_stable cfps
                 left join device dv on dv.id = cfps.device_id
                 left join user u1 on u1.id = cfps.checker_id
                 left join user u2 on u2.id = cfps.tester_id
    </select>
 
    <select id="getCalibrationDate" resultType="java.util.Map">
        SELECT
            d.device_name deviceName,
            d.management_number managementNumber,
            date_format(dmr.calibration_date,'%Y-%m-%d') calibrationDate,
            date_format(dmr.next_calibration_date,'%Y-%m-%d') nextCalibrationDate
        FROM
            device d
                LEFT JOIN device_metric_record dmr ON dmr.device_id = d.id
                AND dmr.type = 'calibrate'
        where d.id = #{deviceId}
        GROUP BY
            d.id
    </select>
 
    <!-- 查询电源稳定性 -->
    <select id="selectPowerStable" resultType="com.ruoyi.require.dto.FePowerStableExportDto">
        SELECT cfps.*,
               dv.device_name,
               dv.management_number,
               DATE_FORMAT(cfps.test_date, '%Y-%m-%d') testDateString,
               DATE_FORMAT(d.calibration_date, '%Y-%m-%d') calibrationDateString,
               DATE_FORMAT(d.next_calibration_date, '%Y-%m-%d') nextCalibrationDateString
        FROM cnas_fe_power_stable cfps
                 left join device dv on dv.id = cfps.device_id
                 LEFT JOIN (SELECT d.id,
                                   dmr.calibration_date,
                                   dmr.next_calibration_date
                            FROM device d
                                     LEFT JOIN device_metric_record dmr ON dmr.device_id = d.id
                                AND dmr.type = 'calibrate'
                            GROUP BY d.id
                            HAVING max(dmr.id)) d ON d.id = cfps.device_id
                 left join user u1 on u1.id = cfps.checker_id
                 left join user u2 on u2.id = cfps.tester_id
        where cfps.power_stable_id = #{powerStableId}
    </select>
</mapper>