ZQN
2024-07-23 51ad03fcc8ffdb52469216558031a1bd31ed1fa6
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
<?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.project.enforce.mapper.EnforceOrderMapper">
 
    <resultMap type="EnforceOrderVo" id="EnforceOrderResult">
        <result property="orderId"    column="order_id"    />
        <result property="orderNo"    column="order_no"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyName"    column="company_name"    />
        <result property="companyCode"    column="company_code"    />
        <result property="companyUser"    column="company_user"    />
        <result property="companyPhone"    column="company_phone"    />
        <result property="companyAddress"    column="company_address"    />
        <result property="regionCode"    column="region_code"    />
        <result property="regionName"    column="region_name"    />
        <result property="enforceContent"    column="enforce_content"    />
        <result property="enforceReason"    column="enforce_reason"    />
        <result property="enforceType"    column="enforce_type"    />
        <result property="applyId"    column="apply_id"    />
        <result property="applyUser"    column="apply_user"    />
        <result property="applyPhone"    column="apply_phone"    />
        <result property="applyDeptId"    column="apply_dept_id"    />
        <result property="applyDeptName"    column="apply_dept_name"    />
        <result property="applyTime"    column="apply_time"    />
        <result property="planTime"    column="plan_time"    />
        <result property="inTime"    column="in_time"    />
        <result property="userNum"    column="user_num"    />
        <result property="warnStatus"    column="warn_status"    />
        <result property="warnReason"    column="warn_reason"    />
        <result property="orderStatus"    column="order_status"    />
        <result property="checkDeptId"    column="check_dept_id"    />
        <result property="checkDeptName"    column="check_dept_name"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="checkReason"    column="check_reason"    />
        <result property="checkLevel"    column="check_level"    />
        <result property="executeId"    column="execute_id"    />
        <result property="executeUser"    column="execute_user"    />
        <result property="executePhone"    column="execute_phone"    />
        <result property="executeDeptId"    column="execute_dept_id"    />
        <result property="executeDeptName"    column="execute_dept_name"    />
        <result property="executeTime"    column="execute_time"    />
        <result property="regionStatus"    column="region_status"    />
        <result property="regionReason"    column="region_reason"    />
        <result property="regionImgs"    column="region_imgs"    />
        <result property="regionVideos"    column="region_videos"    />
        <result property="isNoticeCompany"    column="is_notice_company"    />
        <result property="isShow"    column="is_show"    />
        <result property="isEva"    column="is_eva"    />
        <result property="totalScore"    column="total_score"    />
    </resultMap>
 
    <sql id="selectEnforceOrderVo">
        select *
        from enforce_order
    </sql>
 
    <select id="selectCheckList"
            parameterType="EnforceOrderQueryBo"
            resultMap="EnforceOrderResult">
        <include refid="selectEnforceOrderVo"/>
        where 1=1
            and check_status !=2
            and check_status!=-1
            <if test="orderNo != null and orderNo != ''">
                AND order_no like concat('%', #{orderNo}, '%')
            </if>
            <if test="companyName != null and companyName != ''">
                AND company_name like concat('%', #{companyName}, '%')
            </if>
            <if test="orderStatus != null and orderStatus != ''">
                AND order_status = #{orderStatus}
            </if>
            <if test="checkIds != null and checkIds != '' ">
                AND check_ids like concat('%', #{checkIds}, '%')
            </if>
            <if test="enforceReason != null and enforceReason != '' ">
                AND enforce_reason like concat('%', #{enforceReason}, '%')
            </if>
            <if test="applyDeptIds != null and applyDeptIds !='' ">
                AND apply_dept_id in
                <foreach collection="applyDeptIds" item="applyDeptId" open="(" separator="," close=")">
                    #{applyDeptId}
                </foreach>
            </if>
        order by apply_time desc
    </select>
 
    <select id="selectCheckedList"
            parameterType="OrderCheckedQueryBo"
            resultMap="EnforceOrderResult">
        select t2.*
            from enforce_check_log t1 join enforce_order t2 on t1.order_id = t2.order_id
        where t2.del_flag = 0
        and t1.check_id = #{userId}
        <if test="checkStatus != null">
            AND t2.check_status = #{checkStatus}
        </if>
        <if test="enforceReason != null and enforceReason != '' ">
            AND t2.enforce_reason like concat('%', #{enforceReason}, '%')
        </if>
        order by t2.apply_time desc
    </select>
 
 
    <select id="selectScanList"
            resultMap="EnforceOrderResult">
        select t2.*
        from enforce_peer t1 join enforce_order t2 on t1.order_id = t2.order_id
        where
            t2.del_flag = 0
            and t2.order_status=2
            AND t1.peer_id = #{userId}
            AND t2.company_code = #{companyCode}
        order by t2.apply_time asc
    </select>
 
 
    <select id="selectDistinctCheckDeptIdAndCompanyId"
            resultType="com.project.enforce.domain.vo.EnforceDistinctVo">
        select t.* from
            (
                SELECT company_id, check_dept_id, SUBSTR(apply_time,1,10) as apply_time_str, count( 1 ) AS apply_num
                FROM enforce_order WHERE warn_status=0
                GROUP BY company_id, check_dept_id,apply_time_str
            ) t
        WHERE
            t.apply_num > 1
    </select>
</mapper>