zouyu
2025-03-01 e7a77fffb72595958d245598c4abe87c6b4b84b6
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
<?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.basic.mapper.IfsInventoryQuantityMapper">
 
    <select id="printLabel" resultType="com.ruoyi.basic.dto.IfsInventoryQuantityDto">
        SELECT io.sample sample_name,
        iiq.supplier_name,
        io.part_detail part_desc,
        io.send_time,
        io.prepare_user,
        io.entrust_code,
        iiq.qty_arrived,
        iiq.buy_unit_meas,
        CASE
        WHEN pp.color IS NOT NULL
        THEN pp.color
        ELSE sto.color
        END   color,
        case
        when iiq.state = 2 then '2'
        when iiq.state = 1 then case
        when ROUND((select count(*)
        from ins_product ip
        where state = 1
        and ins_result is not null
        and ip.ins_sample_id in (select id
        from ins_sample
        where ins_sample.ins_order_id = io.id)) /
        (select count(*)
        from ins_product ip2
        where state = 1
        and ip2.ins_sample_id in
        (select id from ins_sample where ins_sample.ins_order_id = io.id)) *
        100, 2) != 100 then '0'
        else '1' end
        end   labelStatus,
        JSON_OBJECT(
        'sample_ame', io.sample,
        'supplier_name', iiq.supplier_name,
        'part_desc', iiq.part_desc,
        'entrust_code', io.entrust_code
        )         labelBarCode
        FROM ifs_inventory_quantity iiq
        LEFT JOIN  ins_order io on io.id = (SELECT io2.id
        FROM ins_order io2
        WHERE io2.ifs_inventory_id = iiq.id
        and io2.state != -1
        order by io2.send_time desc
        limit 1) COLLATE utf8mb4_general_ci
        LEFT JOIN product_part pp ON pp.part_no = iiq.part_no COLLATE utf8mb4_general_ci
        LEFT JOIN structure_test_object_part sto ON sto.part_no = iiq.part_no COLLATE utf8mb4_general_ci
        WHERE iiq.id in
        <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
            #{val}
        </foreach>
    </select>
    <select id="selectReportCountById" resultType="java.lang.Integer">
        select count(*)
        from ifs_inventory_quantity iiq
                 left join ins_order io on io.ifs_inventory_id = iiq.id and io.state
                 left join ins_report ir on ir.ins_order_id = io.id
        where iiq.id = #{ifsInventoryId}
          and ir.id is not null
    </select>
    <select id="selectIsFirst" resultType="java.lang.Integer">
        select count(*)
        from ifs_inventory_quantity iiq
                 LEFT JOIN ins_order io1 on io1.ifs_inventory_id = iiq.id
            and io1.state != -1
        where io1.part_detail = #{partDetail}
          and iiq.supplier_name = #{supplierName}
          and iiq.receiver_date between #{startOfNextQuarter} and #{endOfQuarter}
    </select>
</mapper>