郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
<?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.gk.hotwork.Mapper.HiddenDangerMapper" >
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.HiddenDanger" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="level" property="level" jdbcType="VARCHAR" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="VARCHAR" />
    <result column="requestor" property="requestor" jdbcType="VARCHAR" />
    <result column="requestorid" property="requestorid" jdbcType="BIGINT" />
    <result column="createtime" property="createtime" jdbcType="TIMESTAMP" />
    <result column="createnote" property="createnote" jdbcType="VARCHAR" />
    <result column="rectifytime" property="rectifytime" jdbcType="TIMESTAMP" />
    <result column="rectifynote" property="rectifynote" jdbcType="VARCHAR" />
    <result column="rectifydeadline" property="rectifydeadline" jdbcType="VARCHAR" />
    <result column="rectifier" property="rectifier" jdbcType="VARCHAR" />
    <result column="rectifierid" property="rectifierid" jdbcType="BIGINT" />
    <result column="rectifymeasure" property="rectifymeasure" jdbcType="VARCHAR" />
    <result column="source" property="source" jdbcType="VARCHAR" />
    <result column="validflag" property="validflag" jdbcType="TINYINT" />
    <collection property="rectifyResources"
                ofType="com.gk.hotwork.Domain.HiddenDangerResource"
                select="selectRectifyResources" column="hiddendangerid=id">
 
    </collection>
 
    <collection property="reportResources"
                ofType="com.gk.hotwork.Domain.HiddenDangerResource"
                select="selectReportResources" column="hiddendangerid=id">
 
    </collection>
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, level, status, requestor,, requestorid,
    createtime, createnote,  rectifytime, rectifynote,
     validflag
  </sql>
    <select id="selectPages" resultMap="BaseResultMap">
        select *
        from hiddendanger
        where
        validflag = 1
        <if test="params.requestorid != null and params.requestorid != ''">
          and requestorid = #{params.requestorid}
        </if>
        <if test="params.rectifierid != null and params.rectifierid != ''">
            and rectifierid = #{params.rectifierid}
        </if>
 
        <if test="params.level != null">
          and level = #{params.level}
        </if>
        <if test="params.code != null and params.code != ''">
            and code like concat("%",#{params.code},"%")
        </if>
 
        <if test="params.requestorName != null and params.requestorName != ''">
          and requestor like concat("%", #{params.requestorName},"%")
        </if>
        <if test="params.rectifierName != null and params.rectifierName != ''">
            and rectifier like concat("%", #{params.rectifierName},"%")
        </if>
 
        <if test="params.status != null">
          and status = #{params.status}
        </if>
        <if test="params.source != null and params.source != ''">
          and source = #{params.source}
        </if>
        <if test="params.overTime != null and params.overTime != ''">
            and rectifydeadline &lt; now()
        </if>
 
        order by createtime desc
    </select>
 
  <select id="selectRectifyResources" resultType="com.gk.hotwork.Domain.HiddenDangerResource">
    select *
    from hiddendangerresource
    where operation = 'RECTIFICATION'
    and belongid = #{hiddendangerid}
    and validflag = 1
    order by sort
  </select>
 
  <select id="selectReportResources" resultType="com.gk.hotwork.Domain.HiddenDangerResource">
    select *
    from hiddendangerresource
    where operation = 'REPORT'
    and belongid = #{hiddendangerid}
    and validflag = 1
    order by sort
  </select>
 
    <select id="selectDataGrid" resultType="com.gk.hotwork.Domain.HiddenDanger">
        select
        hiddendanger.*
        from hiddendanger
        LEFT JOIN task on task.`code` = hiddendanger.taskcode
        <where>
            hiddendanger.validflag = 1
            and hiddendanger.`status` IN ("UNCONFIRMED","RECTIFIED")
            <if test="condition.starttime != null and condition.starttime != ''">
                and hiddendanger.`createtime` &gt;= #{condition.starttime}
            </if>
            <if test="condition.endtime != null and condition.endtime != ''">
                and hiddendanger.`createtime` &lt;= #{condition.endtime}
            </if>
 
            <if test="condition.company != null and condition.company != ''">
                and task.constructionunit = #{condition.company}
            </if>
        </where>
    </select>
 
    <select id="selectStatisticsData" resultType="com.gk.hotwork.Domain.HiddenDanger">
        select task.constructionunit,
        COUNT(*) as countNum from hiddendanger
        LEFT JOIN task on task.`code` = hiddendanger.taskcode
        <where>
            hiddendanger.validflag = 1
            and hiddendanger.`status` IN ("UNCONFIRMED","RECTIFIED")
            <if test="condition.starttime != null and condition.starttime != ''">
                and hiddendanger.`createtime` &gt;= #{condition.starttime}
            </if>
            <if test="condition.endtime != null and condition.endtime != ''">
                and hiddendanger.`createtime` &lt;= #{condition.endtime}
            </if>
 
            <if test="condition.company != null and condition.company != ''">
                and task.constructionunit = #{condition.company}
            </if>
        </where>
        group by task.constructionunit
    </select>
    <select id="countNumInMonth" resultType="java.lang.Integer">
        select count(0)
        from hiddendanger
        where requestorid = #{id}
        and date_format(createtime,'%Y-%m') = date_format(now(),'%Y-%m')
    </select>
 
</mapper>