Fixiaobai
2023-09-05 c9da1b0da1178911e383ddcaebecd1e088fa6004
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
<?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.yuanchu.limslaboratory.mapper.InstrumentMapper">
    <select id="getListInstrumentInformation" resultType="map">
        SELECT i.`id`, i.`equipment_code`, i.`equipment_name`, i.`specifications_models`, u.`name`,
        DATE_FORMAT(DATE_ADD(i.`create_time`, INTERVAL i.`term_validity` MONTH), '%Y-%m-%d') termValidity,
        i.`conditions`, i.`storage_place`
        FROM instrument i, `user` u
        WHERE i.`state` = 1
        AND i.`classify_id` = #{classifyId}
        <if test="conditions != null">
            AND i.`conditions` = #{conditions}
        </if>
        <if test="numberOrNameOrSpecifications != null and numberOrNameOrSpecifications != ''">
            AND CONCAT(i.`equipment_code`, i.`equipment_name`, i.`specifications_models`) LIKE
            CONCAT('%',#{numberOrNameOrSpecifications},'%')
        </if>
        <if test="whetherWhether == true">
            AND DATE_FORMAT(DATE_ADD(i.`create_time`, INTERVAL i.`term_validity` MONTH), '%Y-%m-%d') <![CDATA[<]]> NOW()
        </if>
        AND i.`user_id` = u.`id`
    </select>
 
    <!--选择设备-->
    <resultMap id="chooseinstumMap" type="map">
        <id property="id" column="cid"/>
        <result property="name" column="father_name"/>
        <collection property="children" resultMap="chooseinstumTowMap" javaType="List"/>
    </resultMap>
    <resultMap id="chooseinstumTowMap" type="map">
        <id property="id" column="cid"/>
        <result property="name" column="son_name"/>
        <collection property="children" resultMap="chooseinstumTowsMap" javaType="List"/>
    </resultMap>
    <resultMap id="chooseinstumTowsMap" type="map">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="chooseinstum" resultMap="chooseinstumMap">
        select c.id           cid,
               instrument.id,
               father_name,
               son_name,
               equipment_name name
        from lims_laboratory.instrument
                 left join lims_laboratory.classify c on c.id = instrument.classify_id
        where conditions in (1, 5)
    </select>
    <select id="getInstrument" resultMap="treeMapClassAndInstrument">
        SELECT
            *
        FROM
            classify f,(
            SELECT
                cl.id cId,
                cl.son_name cSonName,
                cl.father_name cFatherName,
                i.id iId,
                equipment_name equipmentName
            FROM
                classify cl,
                instrument i
            WHERE
                i.classify_id = cl.id
              AND i.state = 1
              AND conditions = 5
        ) s
        WHERE
            f.father_name = s.cFatherName
          AND f.son_name IS NULL
    </select>
    <select id="getInstrumentAndUser" resultType="java.util.Map">
 
    </select>
 
    <resultMap id="treeMapClassAndInstrument" type="com.yuanchu.limslaboratory.pojo.ClassAndInsTree" >
        <result property="fatherId" column="id"/>
        <result property="fatherName" column="father_name"/>
        <collection property="childrenList" ofType="classAndIns">
            <result property="sonId" column="cId"/>
            <result property="sonName" column="cSonName"/>
            <collection property="childrenList" ofType="ins">
                <result property="insId" column="iId"/>
                <result property="name" column="equipmentName"/>
            </collection>
        </collection>
    </resultMap>
</mapper>