yangys
2024-09-04 04c57331cf84c8f606c2838dcb6fe5463fb9b68c
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?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.cps.mapper.TrayMapper">
 
    <update id="updateFixTure">
        update blade_fixture bf
        set bf.fixture_status = #{status}
        where bf.id in (select btf.fix_id
                        from blade_tray_fixture btf
                        where btf.tray_id = #{id})
    </update>
 
    <select id="trayPage" resultType="com.qianwen.smartman.modules.cps.vo.PageTrayVO">
        select bt.id,
        bt.code,
        bt.name,
        bt.tray_status as trayStatus,
        bt.description,
        bt.category,
        bt.standard_model standardModel,
        bt.availability,
        bt.remark,
        bcg.id groupId,
        bcg.name groupName
        from blade_tray bt
        left join blade_common_group_of_item bcgoi on bt.id = bcgoi.item_id
        left join blade_common_group bcg on bcgoi.group_id = bcg.id
        where bt.is_deleted = 0
        <if test="groupId != null">
            and group_id = #{groupId}
        </if>
        and bcg.is_deleted = 0
        <if test="keyword != null and keyword != ''">
            and (bt.code like concat(#{keyword}, '%') or bt.name like concat(#{keyword}, '%'))
        </if>
        order by bt.create_time desc,bt.id desc
    </select>
 
    <select id="trayTree" resultType="com.qianwen.smartman.modules.cps.vo.ToolingVO">
        SELECT bcg1.id,
               bcg1.code,
               bcg1.name,
               bcg1.parent_id as parentId,
               count(bt.id)      numbers,
               bcg2.name         parentName
        FROM blade_common_group bcg1
                 LEFT JOIN blade_common_group bcg2 on bcg2.id = bcg1.parent_id and bcg2.is_deleted = 0
            AND bcg1.group_type = bcg2.group_type and bcg1.group_category = bcg2.group_category
                 LEFT JOIN blade_common_group_of_item bcgoi on bcgoi.group_id = bcg1.id
                 LEFT JOIN blade_tray bt on bt.id = bcgoi.item_id and bt.is_deleted = 0
        where bcg1.is_deleted = 0
          and bcg1.group_type = #{query.groupType}
          and bcg1.group_category = #{query.groupCategory}
        group by bcg1.id, bcg1.code, bcg1.name, bcg1.parent_id, bcg2.name;
    </select>
 
    <select id="fixtureTree" resultType="com.qianwen.smartman.modules.cps.vo.ToolingVO">
        SELECT bcg1.id,
               bcg1.code,
               bcg1.name,
               bcg1.parent_id as parentId,
               count(bf.id)      numbers,
               bcg2.name         parentName
        FROM blade_common_group bcg1
                 LEFT JOIN blade_common_group bcg2 on bcg2.id = bcg1.parent_id and bcg2.is_deleted = 0
            AND bcg1.group_type = bcg2.group_type and bcg1.group_category = bcg2.group_category
                 LEFT JOIN blade_common_group_of_item bcgoi on bcgoi.group_id = bcg1.id
                 LEFT JOIN blade_fixture bf on bf.id = bcgoi.item_id and bf.is_deleted = 0
        where bcg1.is_deleted = 0
          and bcg1.group_type = #{query.groupType}
          and bcg1.group_category = #{query.groupCategory}
        group by bcg1.id, bcg1.code, bcg1.name, bcg1.parent_id, bcg2.name;
    </select>
 
    <select id="groupTray" resultType="com.qianwen.smartman.modules.cps.vo.TrayTreeVO">
        select bt.id,
               bt.code,
               bt.name,
               bcg.id parentId,
               0 as   isGroup
        from blade_tray bt
                 LEFT JOIN blade_common_group_of_item bcgoi ON bt.id = bcgoi.item_id
                 LEFT JOIN blade_common_group bcg on bcgoi.group_id = bcg.id and bcg.is_deleted = 0
        where bt.is_deleted = 0
    </select>
 
    <select id="unUsedGroupTray" resultType="com.qianwen.smartman.modules.cps.vo.TrayTreeVO">
        select bt.id,
               bt.code,
               bt.name,
               bcg.id parentId,
               0 as   isGroup
        from blade_tray bt
                 LEFT JOIN blade_common_group_of_item bcgoi ON bt.id = bcgoi.item_id
                 LEFT JOIN blade_common_group bcg on bcgoi.group_id = bcg.id and bcg.is_deleted = 0
        where bt.is_deleted = 0
          and bt.in_use = 0
    </select>
 
    <select id="removeFaceFixture" resultType="java.lang.Integer">
        select count(*)
        from blade_fixture bf
        where bf.is_deleted = 0
        and exists(select *
        from blade_production_craft_process_related_fixture bpcprf
        where bpcprf.fixture_id = bf.id
        and exists(select *
        from blade_tray_fixture btf
        where bpcprf.fixture_id = btf.fix_id
        and btf.is_deleted = 0
        and btf.tray_id in
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>)
        )
    </select>
 
    <select id="getWarehouseAreaTrayList" resultType="com.qianwen.smartman.modules.fms.vo.FmsWarehouseAreaTrayVO">
        SELECT bt.code code,
        bt.availability availability,
        bfrtt.current_position currentPosition,
        bfrtt.current_station currentStation,
        bfrtt.order_code orderCode,
        bfrtt.process_code processCode,
        bfrtt.components_number componentsNumber,
        bfrtt.part_type partType,
        bfrtt.order_id orderId,
        fo.product_code productCode
        FROM blade_tray bt
        LEFT JOIN blade_tray_storage bts ON bt.id = bts.tray_id and bts.is_deleted = 0
        LEFT JOIN blade_warehouse_station bws ON bws.id = bts.warehouse_station_id and bws.is_deleted = 0
        LEFT JOIN blade_fms_real_time_tray bfrtt ON bfrtt.tray_code = bt.code and bfrtt.is_deleted = 0
        LEFT JOIN blade_fms_order fo on fo.id=bfrtt.order_id and fo.is_deleted = 0
        WHERE bt.is_deleted = 0
        <if test="areaId != null">
            and bws.area_id = #{areaId}
        </if>
        order by bt.create_time desc, bt.id desc
    </select>
 
    <select id="getWarehouseAreaTray" resultType="com.qianwen.smartman.modules.cps.dto.TrayWarehouseAreaDTO">
        SELECT bt.CODE  trayCode,
               bwa.code areaCode
        FROM blade_tray bt
                 LEFT JOIN blade_tray_storage bts ON bt.id = bts.tray_id
            AND bts.is_deleted = 0
                 LEFT JOIN blade_warehouse_station bws ON bws.id = bts.warehouse_station_id
            AND bws.is_deleted = 0
                 LEFT JOIN blade_fms_real_time_tray bfrtt ON bfrtt.tray_code = bt.CODE
            AND bfrtt.is_deleted = 0
                 LEFT JOIN blade_warehouse_area bwa on bwa.id = bws.area_id
        WHERE bt.is_deleted = 0
          AND bfrtt.tray_code IS NOT NULL
          and bwa.code is not null
    </select>
</mapper>