邱宇豪
2023-10-26 5336eab18039e814aebe78e14b07a4baf50fd560
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
<?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.thhy.secure.modules.biz.pipereport.mapper.PipeReportMapper">
 
 
   <select id="getPipeReportList" resultType="com.thhy.secure.modules.biz.pipereport.entity.PipeReportEntity">
 
       SELECT
               c.pro_id proId,
               c.pro_name proName,
               IFNULL(c.produceTotal,0) produceTotal,
               IFNULL(d.qualifiedTotal,0) qualifiedTotal,
               IFNULL(e.shippingNum,0) shippingNum
       FROM      (
                         SELECT
                             COUNT(a.pro_id) produceTotal,
                             b.pro_id,
                             b.pro_name
                         FROM  sys_project b
                         LEFT JOIN t_pipe_info a on b.pro_id = a.pro_id
                         WHERE b.is_use =1 and b.company_id = #{companyId}
                         GROUP BY b.pro_id
                         ) c
                         LEFT JOIN
                         (
                                 SELECT
                                         COUNT(a.pro_id) qualifiedTotal,
                                         a.pro_id,
                                         b.pro_name
                                 FROM t_pipe_info a
                                              LEFT JOIN sys_project b on b.pro_id = a.pro_id
                                 WHERE a.check_result = 1 and b.company_id = #{companyId}
                                 GROUP BY a.pro_id
                                 ) d ON d.pro_id = c.pro_id
                         LEFT JOIN
                         (
                                 SELECT
                                         COUNT(a.pro_id) shippingNum,
                                         a.pro_id,
                                         b.pro_name
                                 FROM t_pipe_out a
                                              LEFT JOIN sys_project b on b.pro_id = a.pro_id
                                 WHERE b.company_id = #{companyId}
                                 GROUP BY a.pro_id
                                 ) e on e.pro_id = c.pro_id
 
   </select>
 
    <select id="getSteelReportList" resultType="com.thhy.secure.modules.biz.pipereport.entity.PipeReportEntity">
                SELECT
                        c.pro_id proId,
                        c.pro_name proName,
                        IFNULL(c.produceTotal,0) produceTotal,
                        IFNULL(d.qualifiedTotal,0) qualifiedTotal,
                        IFNULL(e.moldedNotNum,0) moldedNotNum,
                        IFNULL(f.moldedNum,0) moldedNum
                FROM(
                            SELECT
                                    COUNT(a.pro_id) produceTotal,
                                    b.pro_id,
                                    b.pro_name
                            FROM sys_project b
                                         LEFT JOIN t_steel_produce a on b.pro_id = a.pro_id
                            WHERE b.is_use =1 and b.company_id = #{companyId}
                            GROUP BY b.pro_id
 
                            ) c
                            LEFT JOIN
                            (
                                    SELECT
                                            COUNT(a.pro_id) qualifiedTotal,
                                            a.pro_id,
                                            b.pro_name
                                    FROM t_steel_produce a
                                                 LEFT JOIN sys_project b on b.pro_id = a.pro_id
                                    WHERE a.is_qualified = 1 and a.is_use = 1  and b.company_id = #{companyId}
                                    GROUP BY a.pro_id
                                    ) d ON d.pro_id = c.pro_id
                            LEFT JOIN
                            (
                                    SELECT
                                            COUNT(a.pro_id) moldedNotNum,
                                            a.pro_id,
                                            b.pro_name
                                    FROM t_steel_produce a
                                                 LEFT JOIN sys_project b on b.pro_id = a.pro_id
                                    WHERE a.is_model = 2 and a.is_use = 1  and b.company_id = #{companyId}
                                    GROUP BY a.pro_id
                                    ) e on e.pro_id = c.pro_id
                            LEFT JOIN
                            (
                                    SELECT
                                            COUNT(a.pro_id) moldedNum,
                                            a.pro_id,
                                            b.pro_name
                                    FROM t_steel_produce a
                                                 LEFT JOIN sys_project b on b.pro_id = a.pro_id
                                    WHERE a.is_model = 1 and a.is_use = 1  and b.company_id = #{companyId}
                                    GROUP BY a.pro_id
                                    ) f on f.pro_id = c.pro_id
    </select>
 
</mapper>