zf
2023-08-30 464fe41610a39c3a06f070d5a01c930134ff0163
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?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.CompanyInfoMapper" >
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.CompanyInfo" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="company" property="company" jdbcType="VARCHAR" />
    <result column="contactname" property="contactname" jdbcType="VARCHAR" />
    <result column="contactphone" property="contactphone" jdbcType="VARCHAR" />
    <result column="ismain" property="ismain" jdbcType="TINYINT" />
    <result column="province" property="province" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="area" property="area" jdbcType="VARCHAR" />
    <result column="town" property="town" jdbcType="VARCHAR" />
    <result column="community" property="community" jdbcType="VARCHAR" />
    <result column="isdel" property="isdel" jdbcType="TINYINT" />
    <result column="createdby" property="createdby" jdbcType="VARCHAR" />
    <result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
    <result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
    <result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
    <result column="longitude" property="longitude" jdbcType="VARCHAR" />
    <result column="latitude" property="latitude" jdbcType="VARCHAR" />
    <result column="isbanned" property="isbanned" jdbcType="TINYINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id,code,company, contactname, contactphone, ismain, province, city, area, town, community, isdel,
    createdby,createddate, lastmodifiedby, lastmodifieddate, longitude, latitude, isbanned
  </sql>
<!--
  <select id="selectDataGrid" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select *
    from company
    <where>
      1=1
      and isdel = 0
      <if test="condition.company != null and condition.company !=''">
        and company like concat('%',#{condition.company},'%')
      </if>
      <if test="condition.companyid != null ">
        and id = #{condition.companyid}
      </if>
      <if test="condition.province != null and condition.province !=''">
        and province = #{condition.province}
      </if>
      <if test="condition.city != null and condition.city !=''">
        and city = #{condition.city}
      </if>
      <if test="condition.area != null and condition.area !=''">
        and area = #{condition.area}
      </if>
      <if test="condition.town != null and condition.town !=''">
        and town like concat('%',#{condition.town},'%')
      </if>
      <if test="condition.community != null and condition.community !=''">
        and community like concat('%',#{condition.community},'%')
      </if>
      <if test="condition.isMain != null ">
        and ismain = #{condition.isMain}
      </if>
    </where>
  </select>
-->
  <select id="selectDataGrid" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select c.*
    from
    (select *
    from company
    <where>
      1=1
      and isdel = 0
      <if test="condition.province != null and condition.province !=''">
        and province = #{condition.province}
      </if>
      <if test="condition.city != null and condition.city !=''">
        and city = #{condition.city}
      </if>
      <if test="condition.area != null and condition.area !=''">
        and area = #{condition.area}
      </if>
    </where>
    union
    select *
    from company
    <where>1=1
      and
      isdel = 0
      and province in(null,'')
    </where>) c
    <where>
        1=1
      <if test="condition.company != null and condition.company !=''">
        and c.company like concat('%',#{condition.company},'%')
      </if>
      <if test="condition.companyid != null ">
        and c.id = #{condition.companyid}
      </if>
    </where>
 
  </select>
 
  <select id="selectExistByName" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select *
    from company
    <where>
      isdel = 0
      and company = #{company}
      <if test="id != null">
      and id != #{id}
      </if>
    </where>
  </select>
  <select id="selectByAll" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select *
    from company
    where isdel = 0
    and isbanned = 0
  </select>
  <select id="selectExistMain" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select *
    from company
    where isdel = 0
      and ismain = 1
    <if test="id != null">
      and id != #{id}
    </if>
    limit 1
  </select>
  <select id="selectCompanyList" resultType="com.gk.hotwork.Domain.CompanyInfo">
    select *
    from company
    <where>
      1=1
      and isdel = 0
      <if test="query.companyid != null and query.companyid !=''">
        and id = #{query.companyid}
      </if>
      <if test="query.company != null and query.company !=''">
        and company like concat('%',#{query.company},'%')
      </if>
      <if test="query.province != null and query.province !=''">
        and province = #{query.province}
      </if>
      <if test="query.city != null and query.city !=''">
        and city = #{query.city}
      </if>
      <if test="query.area != null and query.area !=''">
        and area = #{query.area}
      </if>
    </where>
  </select>
  <select id="getCountByArea" resultType="java.lang.Integer">
    SELECT count(*) FROM company
    where isdel = 0
    <if test="params.province != null and params.province !=''">
      and province = #{params.province}
    </if>
    <if test="params.city != null and params.city !=''">
      and city = #{params.city}
    </if>
    <if test="params.area != null and params.area !=''">
      and area = #{params.area}
    </if>
  </select>
 
  <select id="getUncheckCompanyByArea"  resultType="com.gk.hotwork.Domain.CompanyInfo">
    SELECT
      c1.*
    FROM
      company c1
    WHERE
      c1.isdel = 0
      <if test="query.province != null and query.province !=''">
        and c1.province = #{query.province}
      </if>
      <if test="query.city != null and query.city !=''">
        and c1.city = #{query.city}
      </if>
      <if test="query.area != null and query.area !=''">
        and c1.area = #{query.area}
      </if>
      AND c1.id NOT IN (
      SELECT
        s.checked_company_id
      FROM
        safety_self_inspection s
          INNER JOIN company c ON c.id = s.checked_company_id
      WHERE
        s.valid_flag = 1
        AND s.flag = 2
        <if test="query.province != null and query.province !=''">
          and c.province = #{query.province}
        </if>
        <if test="query.city != null and query.city !=''">
          and c.city = #{query.city}
        </if>
        <if test="query.area != null and query.area !=''">
          and c.area = #{query.area}
        </if>
        <if test="query.startTime != null" >
          and s.inspection_time <![CDATA[ >= ]]> #{query.startTime}
        </if>
        <if test="query.endTime != null" >
          and s.inspection_time <![CDATA[ <= ]]> #{query.endTime}
        </if>
      GROUP BY
        s.checked_company_id
    )
  </select>
</mapper>