btyjj-inspection/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml

717 lines
26 KiB
XML
Raw Normal View History

2020-03-26 00:00:48 +08:00
<?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.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao">
<resultMap id="enterpriseOfGridOperatorDTO" type="com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO">
<id column="enterprise_of_grid_operator_id" property="enterpriseOfGridOperatorId"/>
<result column="user_id" property="userId"/>
<result column="user_count" property="userCount"/>
2020-03-26 00:00:48 +08:00
<result column="enterprise_id" property="enterpriseId"/>
<result column="name_join_by_enterprise_id" property="nameJoinByEnterpriseId"/>
<result column="type_join_by_enterprise_id" property="typeJoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="type_dictionary_name" property="typeDictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="area1_join_by_enterprise_id" property="area1JoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="area1_dictionary_name" property="area1DictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="area2_join_by_enterprise_id" property="area2JoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="area2_dictionary_name" property="area2DictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="area3_join_by_enterprise_id" property="area3JoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="area3_dictionary_name" property="area3DictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="area4_join_by_enterprise_id" property="area4JoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="area4_dictionary_name" property="area4DictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="area5_join_by_enterprise_id" property="area5JoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="area5_dictionary_name" property="area5DictionaryName"/>
2020-03-26 00:00:48 +08:00
<result column="address_join_by_enterprise_id" property="addressJoinByEnterpriseId"/>
<result column="industry_join_by_enterprise_id" property="industryJoinByEnterpriseId"/>
<result column="engaged_count_join_by_enterprise_id" property="engagedCountJoinByEnterpriseId"/>
<result column="risk_operation_join_by_enterprise_id" property="riskOperationJoinByEnterpriseId"/>
<result column="master_join_by_enterprise_id" property="masterJoinByEnterpriseId"/>
<result column="phone_join_by_enterprise_id" property="phoneJoinByEnterpriseId"/>
2020-03-28 23:13:59 +08:00
<result column="industry_dictionary_name" property="industryDictionaryName"/>
<result column="risk_operation_dictionary_name" property="riskOperationDictionaryName"/>
2020-04-09 20:49:13 +08:00
<result column="industry_type_join_by_enterprise_id" property="industryTypeJoinByEnterpriseId"/>
<result column="industry_type_dictionary_name" property="industryTypeDictionaryName"/>
<result column="legal_person" property="legalPerson"/>
2020-04-16 19:58:22 +08:00
<result column="classify_by_enterprise_id" property="classifyJoinByEnterpriseId"/>
<result column="classify_dictionary_name" property="classifyDictionaryName"/>
<result column="nature_by_enterprise_id" property="natureJoinByEnterpriseId"/>
<result column="nature_dictionary_name" property="natureDictionaryName"/>
2020-04-18 18:52:43 +08:00
<result column="is_log_off_by_enterprise_id" property="isLogOffByEnterpriseId"/>
2020-03-26 00:00:48 +08:00
</resultMap>
2020-04-19 00:24:02 +08:00
<resultMap id="gridPersonnelDTO" type="com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO">
<id column="grid_personnel_id" property="gridPersonnelId"/>
<result column="user_id" property="userId"/>
<result column="user_name" property="userName"/>
<result column="area1" property="area1"/>
<result column="area1_dictionary_name" property="area1DictionaryName"/>
<result column="area2" property="area2"/>
<result column="area2_dictionary_name" property="area2DictionaryName"/>
<result column="area3" property="area3"/>
<result column="area3_dictionary_name" property="area3DictionaryName"/>
<result column="area4" property="area4"/>
<result column="area4_dictionary_name" property="area4DictionaryName"/>
<result column="area5" property="area5"/>
<result column="area5_dictionary_name" property="area5DictionaryName"/>
<result column="leader_user_id" property="leaderUserId"/>
<result column="user_id_join_by_leader_user_id" property="userIdJoinByLeaderUserId"/>
<result column="area1_join_by_leader_user_id" property="area1JoinByLeaderUserId"/>
<result column="area2_join_by_leader_user_id" property="area2JoinByLeaderUserId"/>
<result column="area3_join_by_leader_user_id" property="area3JoinByLeaderUserId"/>
<result column="area4_join_by_leader_user_id" property="area4JoinByLeaderUserId"/>
<result column="area5_join_by_leader_user_id" property="area5JoinByLeaderUserId"/>
<result column="leader_user_id_join_by_leader_user_id" property="leaderUserIdJoinByLeaderUserId"/>
<result column="is_grid_operator_join_by_leader_user_id" property="isGridOperatorJoinByLeaderUserId"/>
<result column="level_join_by_leader_user_id" property="levelJoinByLeaderUserId"/>
<result column="is_grid_operator" property="isGridOperator"/>
<result column="level" property="level"/>
</resultMap>
2020-03-26 00:00:48 +08:00
<!-- 新增网格员的企业 -->
2020-07-17 20:36:13 +08:00
<insert id="saveEnterpriseOfGridOperator" parameterType="map" flushCache="true">
2020-03-26 00:00:48 +08:00
INSERT INTO gen_enterprise_of_grid_operator(
enterprise_of_grid_operator_id,
user_id,
enterprise_id,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{enterpriseOfGridOperatorId},
#{userId},
#{enterpriseId},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除网格员的企业 -->
2020-07-17 20:36:13 +08:00
<update id="removeEnterpriseOfGridOperator" parameterType="map" flushCache="true">
2020-03-26 00:00:48 +08:00
UPDATE
gen_enterprise_of_grid_operator
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_of_grid_operator_id IN
<foreach collection="enterpriseOfGridOperatorIds" index="index" open="(" separator="," close=")">
#{enterpriseOfGridOperatorIds[${index}]}
</foreach>
</update>
2020-03-28 23:13:59 +08:00
<!-- 删除网格员的企业(物理删除) -->
2020-07-17 20:36:13 +08:00
<delete id="deleteEnterpriseOfGridOperator" flushCache="true">
2020-03-28 23:13:59 +08:00
DELETE FROM
gen_enterprise_of_grid_operator
WHERE
<if test="enterpriseOfGridOperatorIds != null and enterpriseOfGridOperatorIds.size > 0">
2020-03-28 23:13:59 +08:00
enterprise_of_grid_operator_id IN
<foreach collection="enterpriseOfGridOperatorIds" index="index" open="(" separator="," close=")">
#{enterpriseOfGridOperatorIds[${index}]}
</foreach>
</if>
<if test="enterpriseId != null and enterpriseId != '' and userId != null and userId != ''">
enterprise_id = #{enterpriseId}
AND
user_id = #{userId}
</if>
2020-03-28 23:13:59 +08:00
</delete>
2020-03-26 00:00:48 +08:00
<!-- 修改网格员的企业 -->
2020-07-17 20:36:13 +08:00
<update id="updateEnterpriseOfGridOperator" parameterType="map" flushCache="true">
2020-03-26 00:00:48 +08:00
UPDATE
gen_enterprise_of_grid_operator
SET
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="enterpriseId != null and enterpriseId != ''">
enterprise_id = #{enterpriseId},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_of_grid_operator_id = #{enterpriseOfGridOperatorId}
</update>
<!-- 网格员的企业详情 -->
<select id="getEnterpriseOfGridOperator" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.user_id,
t1.enterprise_id,
t1.enterprise_of_grid_operator_id
FROM
gen_enterprise_of_grid_operator t1
WHERE
t1.is_delete = 0
<if test="enterpriseOfGridOperatorId != null and enterpriseOfGridOperatorId != ''">
AND
t1.enterprise_of_grid_operator_id = #{enterpriseOfGridOperatorId}
</if>
</select>
<!-- 网格员的企业列表 -->
<select id="listEnterpriseOfGridOperator" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.user_id,
t1.enterprise_id,
jt1.name name_join_by_enterprise_id,
jt1.type type_join_by_enterprise_id,
jt1.address address_join_by_enterprise_id,
jt1.master master_join_by_enterprise_id,
jt1.phone phone_join_by_enterprise_id,
2020-03-30 17:08:24 +08:00
jt1.industry industry_join_by_enterprise_id,
jt1.engaged_count engaged_count_join_by_enterprise_id,
jt1.risk_operation risk_operation_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
jt1.area1_dictionary_name,
jt1.area2_dictionary_name,
jt1.area3_dictionary_name,
jt1.area4_dictionary_name,
jt1.area5_dictionary_name,
2020-04-16 19:58:22 +08:00
jt1.classify classify_by_enterprise_id,
jt1.classify_dictionary_name,
jt1.nature nature_by_enterprise_id,
jt1.nature_dictionary_name,
2020-04-18 18:52:43 +08:00
jt1.is_log_off is_log_off_by_enterprise_id,
2020-04-27 19:42:46 +08:00
jt1.legal_person,
2020-03-26 00:00:48 +08:00
t1.enterprise_of_grid_operator_id
FROM
gen_enterprise_of_grid_operator t1
2020-04-15 23:27:59 +08:00
INNER JOIN
2020-03-26 00:00:48 +08:00
gen_enterprise jt1
ON
t1.enterprise_id = jt1.enterprise_id
AND
jt1.is_delete = 0
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
2020-03-30 08:23:38 +08:00
AND
jt1.name LIKE CONCAT('%', #{keywords}, '%')
2020-03-26 00:00:48 +08:00
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="enterpriseOfGridOperatorIds != null and enterpriseOfGridOperatorIds.size > 0">
AND
t1.enterprise_of_grid_operator_id IN
<foreach collection="enterpriseOfGridOperatorIds" index="index" open="(" separator="," close=")">
#{enterpriseOfGridOperatorIds[${index}]}
</foreach>
</if>
2020-03-30 08:23:38 +08:00
<if test="userId != null and userId != ''">
AND
t1.user_id = #{userId}
</if>
2020-04-18 18:52:43 +08:00
<if test="withOutLogOff != null and withOutLogOff == 'withOutLogOff'">
AND
jt1.is_log_off = 0
</if>
2020-04-01 17:54:50 +08:00
<if test="type != null and type != ''">
AND
jt1.type = #{type}
</if>
2020-03-30 08:23:38 +08:00
<if test="area1 != null and area1 != ''">
AND
jt1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
jt1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
jt1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
jt1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
jt1.area5 = #{area5}
</if>
2020-03-28 23:13:59 +08:00
</select>
<!-- 网格员的企业列表通过用户ID,性能问题废弃 -->
<select id="listEnterpriseOfGridOperatorByUserIdDiscard" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
2020-03-28 23:13:59 +08:00
SELECT
2020-03-26 00:00:48 +08:00
t1.enterprise_id,
2020-03-28 23:13:59 +08:00
t1.name name_join_by_enterprise_id,
t1.type type_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.type_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.area1 area1_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.area1_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.area2 area2_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.area2_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.area3 area3_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.area3_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.area4 area4_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.area4_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.area5 area5_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.area5_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.address address_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.industry_type industry_type_join_by_enterprise_id,
t1.industry_type_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.industry industry_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.industry_dictionary_name,
2020-03-28 23:13:59 +08:00
t1.engaged_count engaged_count_join_by_enterprise_id,
t1.risk_operation risk_operation_join_by_enterprise_id,
2020-04-09 20:49:13 +08:00
t1.risk_operation_dictionary_name,
t1.legal_person,
2020-03-28 23:13:59 +08:00
t1.master master_join_by_enterprise_id,
t1.phone phone_join_by_enterprise_id,
2020-04-16 19:58:22 +08:00
t1.classify classify_by_enterprise_id,
t1.classify_dictionary_name,
t1.nature nature_by_enterprise_id,
t1.nature_dictionary_name,
2020-04-18 18:52:43 +08:00
t1.is_log_off is_log_off_by_enterprise_id,
2020-03-28 23:13:59 +08:00
jt1.user_id,
jt1.enterprise_of_grid_operator_id
FROM
gen_enterprise t1
LEFT JOIN
gen_enterprise_of_grid_operator jt1
ON
t1.enterprise_id = jt1.enterprise_id
WHERE
t1.is_delete = 0
2020-04-14 18:45:30 +08:00
AND (
jt1.user_id IS NULL
OR
jt1.user_id = #{userId}
)
2020-03-28 23:13:59 +08:00
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="type != null and type != ''">
AND
t1.type = #{type}
</if>
</select>
<!-- 网格员的企业列表通过用户ID -->
<select id="listEnterpriseOfGridOperatorByUserId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
t1.type type_join_by_enterprise_id,
t1.type_dictionary_name,
t1.area1 area1_join_by_enterprise_id,
t1.area1_dictionary_name,
t1.area2 area2_join_by_enterprise_id,
t1.area2_dictionary_name,
t1.area3 area3_join_by_enterprise_id,
t1.area3_dictionary_name,
t1.area4 area4_join_by_enterprise_id,
t1.area4_dictionary_name,
t1.area5 area5_join_by_enterprise_id,
t1.area5_dictionary_name,
t1.address address_join_by_enterprise_id,
2020-05-10 19:52:04 +08:00
t1.industry_type indzustry_type_join_by_enterprise_id,
t1.industry_type_dictionary_name,
t1.industry industry_join_by_enterprise_id,
t1.industry_dictionary_name,
t1.engaged_count engaged_count_join_by_enterprise_id,
t1.risk_operation risk_operation_join_by_enterprise_id,
t1.risk_operation_dictionary_name,
t1.legal_person,
t1.master master_join_by_enterprise_id,
t1.phone phone_join_by_enterprise_id,
t1.classify classify_by_enterprise_id,
t1.classify_dictionary_name,
t1.nature nature_by_enterprise_id,
t1.nature_dictionary_name,
t1.is_log_off is_log_off_by_enterprise_id,
(
SELECT
COUNT(*)
FROM
gen_enterprise_of_grid_operator st1
WHERE
st1.user_id = #{userId}
AND
t1.enterprise_id = st1.enterprise_id
) user_count
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
AND (
t1.enterprise_id IN (
SELECT
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
WHERE
wt1.user_id = #{userId}
) OR t1.enterprise_id NOT IN (
SELECT
wt2.enterprise_id
FROM
gen_enterprise_of_grid_operator wt2
GROUP BY
wt2.enterprise_id
)
)
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
2020-03-28 23:13:59 +08:00
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
2020-04-01 17:54:50 +08:00
<if test="type != null and type != ''">
AND
t1.type = #{type}
</if>
2020-03-26 00:00:48 +08:00
</select>
2020-04-14 18:45:30 +08:00
<!-- 网格员的企业列表通过用户ID和企业ID -->
<select id="listEnterpriseOfGridOperatorByUserIdAndEnterpriseId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
user_id
enterprise_id
FROM
gen_enterprise_of_grid_operator
WHERE
user_id = #{userId}
AND
enterprise_id = #{enterpriseId}
</select>
<!-- 统计绑定的企业 -->
<select id="countEnterpriseOfGridOperator" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_enterprise_of_grid_operator t1
INNER JOIN
gen_enterprise t2
ON
t1.enterprise_id = t2.enterprise_id
AND
t2.is_delete = 0
WHERE
t1.is_delete = 0
<if test="userId != null and userId != ''">
AND
t1.user_id = #{userId}
</if>
</select>
2020-04-19 00:24:02 +08:00
<!-- 网格员列表 -->
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO">
SELECT
jt1.user_id,
jt1.area1,
jt1.area2,
jt1.area3,
jt1.area4,
jt1.area5,
jt1.leader_user_id,
jt1.is_grid_operator,
jt1.level,
jt1.grid_personnel_id
FROM
gen_enterprise_of_grid_operator t1
INNER JOIN
gen_grid_personnel jt1
ON
t1.user_id = LEFT(jt1.user_id, 36)
AND
jt1.is_delete = 0
WHERE
t1.is_delete = 0
<if test="enterpriseId != null and enterpriseId != ''">
AND
t1.enterprise_id = #{enterpriseId}
</if>
</select>
2020-05-10 23:13:21 +08:00
<!-- 未认领企业列表 -->
<select id="listUnclaimedEnterprise" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
t1.type type_join_by_enterprise_id,
t1.type_dictionary_name,
t1.area1 area1_join_by_enterprise_id,
t1.area1_dictionary_name,
t1.area2 area2_join_by_enterprise_id,
t1.area2_dictionary_name,
t1.area3 area3_join_by_enterprise_id,
t1.area3_dictionary_name,
t1.area4 area4_join_by_enterprise_id,
t1.area4_dictionary_name,
t1.area5 area5_join_by_enterprise_id,
t1.area5_dictionary_name,
t1.address address_join_by_enterprise_id,
t1.industry_type indzustry_type_join_by_enterprise_id,
t1.industry_type_dictionary_name,
t1.industry industry_join_by_enterprise_id,
t1.industry_dictionary_name,
t1.engaged_count engaged_count_join_by_enterprise_id,
t1.risk_operation risk_operation_join_by_enterprise_id,
t1.risk_operation_dictionary_name,
t1.legal_person,
t1.master master_join_by_enterprise_id,
t1.phone phone_join_by_enterprise_id,
t1.classify classify_by_enterprise_id,
t1.classify_dictionary_name,
t1.nature nature_by_enterprise_id,
t1.nature_dictionary_name,
t1.is_log_off is_log_off_by_enterprise_id
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
AND
t1.enterprise_id NOT IN (
SELECT
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
GROUP BY
wt1.enterprise_id
)
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
</select>
<!-- 统计未认领企业 -->
<select id="countUnclaimedEnterprise" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
AND
t1.enterprise_id NOT IN (
SELECT
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
GROUP BY
wt1.enterprise_id
)
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
2020-07-15 21:41:17 +08:00
<if test="year != null and year != ''">
AND
LEFT(t1.gmt_create, 4) <![CDATA[ <= ]]> #{year}
</if>
</select>
<!-- 统计认领企业 -->
<select id="countClaimedEnterprise" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
AND
t1.enterprise_id IN (
SELECT
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
GROUP BY
wt1.enterprise_id
)
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="year != null and year != ''">
AND
LEFT(t1.gmt_create, 4) <![CDATA[ <= ]]> #{year}
</if>
2020-05-10 23:13:21 +08:00
</select>
2020-09-15 12:47:36 +08:00
<!-- 统计企业 -->
<select id="countEnterpriseOfGridOperatorSimple" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
gen_enterprise_of_grid_operator t1
WHERE
t1.is_delete = 0
<if test="userId != null and userId != ''">
AND
t1.creator = #{userId}
</if>
<if test="yearMonth != null and yearMonth != ''">
AND
LEFT(t1.gmt_create, 7) <![CDATA[ <= ]]> #{yearMonth}
</if>
<if test="dateYearMonth != null and dateYearMonth != ''">
AND
LEFT(t1.gmt_create, 7) = #{dateYearMonth}
</if>
</select>
<!-- 企业网格员列表(简单格式) -->
<select id="listSimple" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
enterprise_of_grid_operator_id,
user_id,
enterprise_id
FROM
gen_enterprise_of_grid_operator
WHERE
is_delete = 0
<if test="enterpriseIds != null and enterpriseIds.size > 0">
AND
enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</if>
</select>
2021-03-03 18:22:32 +08:00
<!-- 企业ID列表 -->
<select id="listEnterpriseId" parameterType="map" resultType="java.lang.String">
SELECT
enterprise_id
FROM
gen_enterprise_of_grid_operator
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="enterpriseIds != null and enterpriseIds.size > 0">
AND
enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</if>
GROUP BY
enterprise_id
</select>
2020-03-26 00:00:48 +08:00
</mapper>