廖井涛
7 天以前 70a9b5ca60bafe50da533513f99b990147968a93
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
<?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.example.erp.mapper.pp.DamageDetailsMapper">
<select id="getBehindDamageSum">
    SELECT ifnull(SUM(a.breakage_quantity),0)
    FROM pp.damage_details as a
    left join pp.reporting_work as b
    on a.reporting_work_id = b.reporting_work_id
    left join patch_log as c
    on a.reporting_work_id = c.reporting_work_id
           and a.process_id = c.process_id
           and a.order_number = c.order_sort
           and a.technology_number = c.technology_number
    WHERE a.process_id = #{processId}
    <if test="needOrderNumber!=null">
    and a.order_number = #{orderNumber}
    </if>
    and a.available=0
    and a.technology_number =#{technologyNumber}
    and a.breakage_quantity>0
    and b.reviewed_state>=0
    and b.this_process in (WITH RECURSIVE cte AS (
                            SELECT 1 AS n
                            UNION ALL
                            SELECT n + 1 FROM cte WHERE n &lt; 20 -- 这里的 20 是最大拆分个数
                        )
                           SELECT REGEXP_SUBSTR(#{behindProcess}, '[^,]+', 1, n) AS process
                           FROM cte
                           WHERE REGEXP_SUBSTR(#{behindProcess}, '[^,]+', 1, n) IS NOT NULL)
    and ifnull(c.review_status,0) = 0
 
</select>
    <select id="getNotReview">
    select a.*,ifnull(c.review_status,0) as reviewed_state
    from damage_details as a
    left join reporting_work as b
    on a.reporting_work_id = b.reporting_work_id
    left join patch_log as c
    on a.reporting_work_id = c.reporting_work_id and a.process_id = c.process_id and a.order_number = c.order_sort
    and a.technology_number = c.technology_number
    where a.process_id=#{processId}
     and b.reviewed_state>=0
  <if test="orderNumber!= null || orderNumber!=''">
      and a.order_number = #{orderNumber}
  </if>
    and a.available=0
    and a.technology_number = #{technologyNumber}
    and a.breakage_quantity>0
    and ifnull(c.review_status,0) = 0
 
    </select>
</mapper>