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
<?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.qianwen.smartman.modules.tool.mapper.ToolManageMapper">
 
    <select id="getToolTreeList" resultType="com.qianwen.smartman.modules.tool.vo.ToolManageTreeVO">
        select t.id,
               t.code          name,
               t.tool_model_id parentId,
               tc.id           toolCategoryId,
               tc.name         toolCategory,
               tm.id           toolModelId,
               tm.model        toolModel,
               0               isGroup
        from blade_tool t
                 join blade_tool_category tc on tc.id = t.tool_category_id and tc.is_deleted = 0
                 join blade_tool_model tm on tm.id = t.tool_model_id and tm.is_deleted = 0
        where t.is_deleted = 0
    </select>
    <select id="page" resultType="com.qianwen.smartman.modules.tool.vo.ToolManageVO">
        SELECT
        bt.id,
        bt.tool_category_id,
        bt.tool_model_id,
        bt.tool_prefix_code,
        bt.life_count_method,
        bt.initial_life,
        bt.used_life,
        bt.remain_life,
        bt.warning_value,
        bt.life_state,
        bt.use_state,
        bt.workstation_id,
        bt.workstation_code,
        bt.workstation_name,
        bt.tool_position,
        bt.parameter1,
        bt.parameter2,
        bt.parameter3,
        bt.parameter4,
        bt.parameter5,
        bt.parameter6,
        bt.parameter7,
        bt.parameter8,
        bt.parameter9,
        bt.parameter10,
        bt.code,
        btc.name toolCategory,
        btm.model toolModel
        FROM
        blade_tool bt
        LEFT JOIN blade_tool_category btc ON btc.id = bt.tool_category_id
        AND btc.is_deleted = 0
        LEFT JOIN blade_tool_model btm ON btm.id = bt.tool_model_id
        AND btm.is_deleted = 0
        WHERE
        bt.is_deleted = 0
        <if test="toolQueryVO.toolCategoryId != null and toolQueryVO.toolCategoryId != 1">
            AND btc.id = #{toolQueryVO.toolCategoryId}
        </if>
        <if test="toolQueryVO.toolModelId != null">
            AND btm.id = #{toolQueryVO.toolModelId}
        </if>
        <if test="toolQueryVO.useState != null">
            AND bt.use_state = #{toolQueryVO.useState}
        </if>
        <if test="toolQueryVO.lifeState != null">
            AND bt.life_state = #{toolQueryVO.lifeState}
        </if>
        <if test="toolQueryVO.toolPosition != null and toolQueryVO.toolPosition != ''">
            AND bt.tool_position like concat(#{toolQueryVO.toolPosition},'%')
        </if>
        <if test="toolQueryVO.code != null and toolQueryVO.code != ''">
            AND bt.code like concat(#{toolQueryVO.code},'%')
        </if>
        <if test="toolQueryVO.workstationCode != null and toolQueryVO.workstationCode != ''">
            AND bt.workstation_code like concat(#{toolQueryVO.workstationCode},'%')
        </if>
        order by bt.create_time desc,bt.id desc
 
    </select>
</mapper>