btyjj-inspection/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml
2021-08-03 18:08:32 +08:00

803 lines
27 KiB
XML

<?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.enterprise.IEnterpriseDao">
<cache flushInterval="1800000"/>
<resultMap id="enterpriseDTO" type="com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO">
<id column="enterprise_id" property="enterpriseId"/>
<result column="name" property="name"/>
<result column="type" property="type"/>
<result column="type_dictionary_name" property="typeDictionaryName"/>
<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="address" property="address"/>
<result column="industry_type" property="industryType"/>
<result column="industry_type_dictionary_name" property="industryTypeDictionaryName"/>
<result column="industry" property="industry"/>
<result column="industry_dictionary_name" property="industryDictionaryName"/>
<result column="engaged_count" property="engagedCount"/>
<result column="risk_operation" property="riskOperation"/>
<result column="risk_operation_dictionary_name" property="riskOperationDictionaryName"/>
<result column="master" property="master"/>
<result column="master_id_card_front" property="masterIdCardFront"/>
<result column="master_id_card_back" property="masterIdCardBack"/>
<result column="master_legal_certificate" property="masterLegalCertificate"/>
<result column="phone" property="phone"/>
<result column="factory_gate" property="factoryGate"/>
<result column="workplace" property="workplace"/>
<result column="industry_type" property="industryType"/>
<result column="bussiness_reg_num" property="bussinessRegNum"/>
<result column="bussiness_license" property="bussinessLicense"/>
<result column="bussiness_license_start_date" property="bussinessLicenseStartDate"/>
<result column="bussiness_license_end_date" property="bussinessLicenseEndDate"/>
<result column="legal_person" property="legalPerson"/>
<result column="legal_phone" property="legalPhone"/>
<result column="legal_id_card_front" property="legalIdCardFront"/>
<result column="legal_id_card_back" property="legalIdCardBack"/>
<result column="summary" property="summary"/>
<result column="classify" property="classify"/>
<result column="classify_dictionary_name" property="classifyDictionaryName"/>
<result column="nature" property="nature"/>
<result column="nature_dictionary_name" property="natureDictionaryName"/>
<result column="is_log_off" property="isLogOff"/>
<result column="is_commercial_downstairs" property="isCommercialDownstairs"/>
<result column="remarks" property="remarks"/>
<result column="enterprise_lng" property="enterpriseLng"/>
<result column="enterprise_lat" property="enterpriseLat"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<resultMap id="enterprisePollutionDTO" type="com.cm.inspection.pojo.dtos.enterprise.EnterprisePollutionDTO">
<id column="enterprise_id" property="enterpriseId"/>
<result column="pollution_factor" property="pollutionFactor"/>
<result column="enterprise_type" property="enterpriseType"/>
<result column="pollution_factor_dangerous" property="pollutionFactorDangerous"/>
<result column="pollution_factor_other" property="pollutionFactorOther"/>
<result column="pollution_facilities" property="pollutionFacilities"/>
<result column="pollution_control_facilities" property="pollutionControlFacilities"/>
<result column="eia_status" property="eiaStatus"/>
<result column="check_status" property="checkStatus"/>
<result column="related_documents" property="relatedDocuments"/>
</resultMap>
<!-- 新增企业 -->
<insert id="saveEnterprise" parameterType="map" flushCache="true">
INSERT INTO gen_enterprise(
enterprise_id,
name,
type,
area1,
area2,
area3,
area4,
area5,
address,
industry,
engaged_count,
risk_operation,
master,
master_id_card_front,
master_id_card_back,
master_legal_certificate,
phone,
factory_gate,
workplace,
industry_type,
bussiness_reg_num,
bussiness_license,
bussiness_license_start_date,
bussiness_license_end_date,
legal_person,
legal_phone,
legal_id_card_front,
legal_id_card_back,
summary,
type_dictionary_name,
area1_dictionary_name,
area2_dictionary_name,
area3_dictionary_name,
area4_dictionary_name,
area5_dictionary_name,
industry_type_dictionary_name,
industry_dictionary_name,
risk_operation_dictionary_name,
classify,
classify_dictionary_name,
nature,
nature_dictionary_name,
is_log_off,
is_commercial_downstairs,
enterprise_lng,
enterprise_lat,
remarks,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{enterpriseId},
#{name},
#{type},
#{area1},
#{area2},
#{area3},
#{area4},
#{area5},
#{address},
#{industry},
#{engagedCount},
#{riskOperation},
#{master},
#{masterIdCardFront},
#{masterIdCardBack},
#{masterLegalCertificate},
#{phone},
#{factoryGate},
#{workplace},
#{industryType},
#{bussinessRegNum},
#{bussinessLicense},
#{bussinessLicenseStartDate},
#{bussinessLicenseEndDate},
#{legalPerson},
#{legalPhone},
#{legalIdCardFront},
#{legalIdCardBack},
#{summary},
#{typeDictionaryName},
#{area1DictionaryName},
#{area2DictionaryName},
#{area3DictionaryName},
#{area4DictionaryName},
#{area5DictionaryName},
#{industryTypeDictionaryName},
#{industryDictionaryName},
#{riskOperationDictionaryName},
#{classify},
#{classifyDictionaryName},
#{nature},
#{natureDictionaryName},
#{isLogOff},
#{isCommercialDownstairs},
#{enterpriseLng},
#{enterpriseLat},
#{remarks},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除企业 -->
<update id="removeEnterprise" parameterType="map" flushCache="true">
UPDATE
gen_enterprise
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</update>
<!-- 修改企业 -->
<update id="updateEnterprise" parameterType="map" flushCache="true">
UPDATE
gen_enterprise
SET
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="area1 != null">
area1 = #{area1},
</if>
<if test="area2 != null">
area2 = #{area2},
</if>
<if test="area3 != null">
area3 = #{area3},
</if>
<if test="area4 != null">
area4 = #{area4},
</if>
<if test="area5 != null">
area5 = #{area5},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="industry != null">
industry = #{industry},
</if>
<if test="engagedCount != null">
engaged_count = #{engagedCount},
</if>
<if test="riskOperation != null and riskOperation != ''">
risk_operation = #{riskOperation},
</if>
<if test="master != null and master != ''">
master = #{master},
</if>
<if test="masterIdCardFront != null">
master_id_card_front = #{masterIdCardFront},
</if>
<if test="masterIdCardBack != null">
master_id_card_back = #{masterIdCardBack},
</if>
<if test="masterLegalCertificate != null">
master_legal_certificate = #{masterLegalCertificate},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="factoryGate != null">
factory_gate = #{factoryGate},
</if>
<if test="workplace != null">
workplace = #{workplace},
</if>
<if test="industryType != null">
industry_type = #{industryType},
</if>
<if test="bussinessRegNum != null">
bussiness_reg_num = #{bussinessRegNum},
</if>
<if test="bussinessLicense != null">
bussiness_license = #{bussinessLicense},
</if>
<if test="bussinessLicenseStartDate != null">
bussiness_license_start_date = #{bussinessLicenseStartDate},
</if>
<if test="bussinessLicenseEndDate != null">
bussiness_license_end_date = #{bussinessLicenseEndDate},
</if>
<if test="legalPerson != null">
legal_person = #{legalPerson},
</if>
<if test="legalPhone != null">
legal_phone = #{legalPhone},
</if>
<if test="legalIdCardFront != null">
legal_id_card_front = #{legalIdCardFront},
</if>
<if test="legalIdCardBack != null">
legal_id_card_back = #{legalIdCardBack},
</if>
<if test="summary != null and summary != ''">
summary = #{summary},
</if>
<if test="typeDictionaryName != null">
type_dictionary_name = #{typeDictionaryName},
</if>
<if test="area1DictionaryName != null">
area1_dictionary_name = #{area1DictionaryName},
</if>
<if test="area2DictionaryName != null">
area2_dictionary_name = #{area2DictionaryName},
</if>
<if test="area3DictionaryName != null">
area3_dictionary_name = #{area3DictionaryName},
</if>
<if test="area4DictionaryName != null">
area4_dictionary_name = #{area4DictionaryName},
</if>
<if test="area5DictionaryName != null">
area5_dictionary_name = #{area5DictionaryName},
</if>
<if test="industryTypeDictionaryName != null">
industry_type_dictionary_name = #{industryTypeDictionaryName},
</if>
<if test="industryDictionaryName != null">
industry_dictionary_name = #{industryDictionaryName},
</if>
<if test="riskOperationDictionaryName != null">
risk_operation_dictionary_name = #{riskOperationDictionaryName},
</if>
<if test="classify != null and classify != ''">
classify = #{classify},
</if>
<if test="classifyDictionaryName != null">
classify_dictionary_name = #{classifyDictionaryName},
</if>
<if test="nature != null and nature != ''">
nature = #{nature},
</if>
<if test="natureDictionaryName != null">
nature_dictionary_name = #{natureDictionaryName},
</if>
<if test="isLogOff != null">
is_log_off = #{isLogOff},
</if>
<if test="isCommercialDownstairs != null">
is_commercial_downstairs = #{isCommercialDownstairs},
</if>
<if test="enterpriseLng != null">
enterprise_lng = #{enterpriseLng},
</if>
<if test="enterpriseLat != null">
enterprise_lat = #{enterpriseLat},
</if>
<if test="remarks != null">
remarks = #{remarks},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_id = #{enterpriseId}
</update>
<!-- 修改企业位置 -->
<update id="updateEnterpriseLocation" parameterType="map" flushCache="true">
UPDATE
gen_enterprise
SET
<if test="enterpriseLng != null and enterpriseLng != ''">
enterprise_lng = #{enterpriseLng},
</if>
<if test="enterpriseLat != null and enterpriseLat != ''">
enterprise_lat = #{enterpriseLat},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_id = #{enterpriseId}
</update>
<!-- 修改企业场所性质 -->
<update id="updateEnterpriseNature" parameterType="map" flushCache="true">
UPDATE
gen_enterprise
SET
<if test="nature != null and nature != ''">
nature = #{nature},
</if>
<if test="natureDictionaryName != null and natureDictionaryName != ''">
nature_dictionary_name = #{natureDictionaryName},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_id = #{enterpriseId}
</update>
<!-- 修改企业分类 -->
<update id="updateEnterpriseClassify" parameterType="map" flushCache="true">
UPDATE
gen_enterprise
SET
<if test="classify != null and classify != ''">
classify = #{classify},
</if>
<if test="classifyDictionaryName != null and classifyDictionaryName != ''">
classify_dictionary_name = #{classifyDictionaryName},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
enterprise_id = #{enterpriseId}
</update>
<!-- 新增企业污染因子 -->
<insert id="saveEnterprisePollution" parameterType="map" flushCache="true">
INSERT INTO gen_enterprise_pollution(
enterprise_id,
enterprise_type,
pollution_factor,
pollution_factor_dangerous,
pollution_factor_other,
pollution_facilities,
pollution_control_facilities,
eia_status,
check_status,
related_documents
) VALUES(
#{enterpriseId},
#{enterpriseType},
#{pollutionFactor},
#{pollutionFactorDangerous},
#{pollutionFactorOther},
#{pollutionFacilities},
#{pollutionControlFacilities},
#{eiaStatus},
#{checkStatus},
#{relatedDocuments}
)
</insert>
<!-- 更新企业污染因子 -->
<update id="updateEnterprisePollution" parameterType="map" flushCache="true">
UPDATE
gen_enterprise_pollution
SET
<if test="pollutionFactor != null">
pollution_factor = #{pollutionFactor},
</if>
<if test="pollutionFactorDangerous != null">
pollution_factor_dangerous = #{pollutionFactorDangerous},
</if>
<if test="pollutionFactorOther != null">
pollution_factor_other = #{pollutionFactorOther},
</if>
<if test="pollutionFacilities != null">
pollution_facilities = #{pollutionFacilities},
</if>
<if test="pollutionControlFacilities != null">
pollution_control_facilities = #{pollutionControlFacilities},
</if>
<if test="eiaStatus != null">
eia_status = #{eiaStatus},
</if>
<if test="checkStatus != null">
check_status = #{checkStatus},
</if>
<if test="relatedDocuments != null">
related_documents = #{relatedDocuments},
</if>
<if test="enterpriseType != null">
enterprise_type = #{enterpriseType},
</if>
enterprise_id = #{enterpriseId}
WHERE
enterprise_id = #{enterpriseId}
</update>
<!-- 企业详情 -->
<select id="getEnterprise" parameterType="map" resultMap="enterpriseDTO" useCache="true">
SELECT
t1.name,
t1.type,
t1.type_dictionary_name,
t1.area1,
t1.area1_dictionary_name,
t1.area2,
t1.area2_dictionary_name,
t1.area3,
t1.area3_dictionary_name,
t1.area4,
t1.area4_dictionary_name,
t1.area5,
t1.area5_dictionary_name,
t1.address,
t1.industry,
t1.industry_dictionary_name,
t1.engaged_count,
t1.risk_operation,
t1.risk_operation_dictionary_name,
t1.master,
t1.master_id_card_front,
t1.master_id_card_back,
t1.master_legal_certificate,
t1.phone,
t1.factory_gate,
t1.workplace,
t1.industry_type,
t1.industry_type_dictionary_name,
t1.bussiness_reg_num,
t1.bussiness_license,
t1.bussiness_license_start_date,
t1.bussiness_license_end_date,
t1.legal_person,
t1.legal_phone,
t1.legal_id_card_front,
t1.legal_id_card_back,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
t1.is_log_off,
t1.is_commercial_downstairs,
t1.remarks,
t1.enterprise_lng,
t1.enterprise_lat,
t1.enterprise_id
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
<if test="enterpriseId != null and enterpriseId != ''">
AND
t1.enterprise_id = #{enterpriseId}
</if>
</select>
<!-- 企业详情单表 -->
<select id="getEnterpriseSingle" resultMap="enterpriseDTO" useCache="true">
SELECT
t1.name,
t1.type,
t1.area1,
t1.area2,
t1.area3,
t1.area4,
t1.area5,
t1.address,
t1.industry_type,
t1.industry,
t1.engaged_count,
t1.risk_operation,
t1.master,
t1.master_id_card_front,
t1.master_id_card_back,
t1.master_legal_certificate,
t1.phone,
t1.factory_gate,
t1.workplace,
t1.industry_type,
t1.bussiness_reg_num,
t1.bussiness_license,
t1.bussiness_license_start_date,
t1.bussiness_license_end_date,
t1.legal_person,
t1.legal_phone,
t1.legal_id_card_front,
t1.legal_id_card_back,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
t1.is_log_off,
t1.is_commercial_downstairs,
t1.remarks,
t1.enterprise_lng,
t1.enterprise_lat,
t1.enterprise_id
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
<if test="enterpriseId != null and enterpriseId != ''">
AND
t1.enterprise_id = #{enterpriseId}
</if>
</select>
<!-- 企业列表 -->
<select id="listEnterprise" parameterType="map" resultMap="enterpriseDTO" useCache="true">
SELECT
t1.name,
t1.type,
t1.type_dictionary_name,
t1.area1,
t1.area1_dictionary_name,
t1.area2,
t1.area2_dictionary_name,
t1.area3,
t1.area3_dictionary_name,
t1.area4,
t1.area4_dictionary_name,
t1.area5,
t1.area5_dictionary_name,
t1.address,
t1.industry,
t1.industry_dictionary_name,
t1.engaged_count,
t1.risk_operation,
t1.risk_operation_dictionary_name,
t1.master,
t1.master_id_card_front,
t1.master_id_card_back,
t1.master_legal_certificate,
t1.phone,
t1.industry_type,
t1.industry_type_dictionary_name,
t1.bussiness_reg_num,
t1.bussiness_license,
t1.bussiness_license_start_date,
t1.bussiness_license_end_date,
t1.legal_person,
t1.legal_phone,
t1.legal_id_card_front,
t1.legal_id_card_back,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
t1.is_log_off,
t1.is_commercial_downstairs,
t1.remarks,
t1.enterprise_lng,
t1.enterprise_lat,
LEFT(t1.gmt_create, 19) gmt_create,
t1.enterprise_id
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</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="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="remarks != null and remarks != ''">
AND
t1.remarks = #{remarks}
</if>
<if test="industryType != null and industryType != ''">
AND
t1.industry_type = #{industryType}
</if>
<if test="enterpriseIds != null and enterpriseIds.size > 0">
AND
t1.enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</if>
</select>
<!-- 统计企业 -->
<select id="countEnterprise" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
gen_enterprise
WHERE
is_delete = 0
<if test="isLogOff != null">
AND
is_log_off = #{isLogOff}
</if>
<if test="nature != null and nature != ''">
AND
nature = #{nature}
</if>
<if test="area3 != null and area3 != ''">
AND
area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
area5 = #{area5}
</if>
<if test="industryType != null and industryType != ''">
AND
industry_type = #{industryType}
</if>
<if test="industry != null and industry != ''">
AND
industry = #{industry}
</if>
<if test="year != null and year != ''">
AND
LEFT(gmt_create, 4) <![CDATA[ <= ]]> #{year}
</if>
</select>
<!-- 用户企业列表 -->
<select id="listEnterpriseByUser" parameterType="map" resultMap="enterpriseDTO" useCache="true">
SELECT
jt1.*
FROM
gen_enterprise_of_grid_operator t1
INNER JOIN
gen_enterprise jt1
ON
t1.enterprise_id = jt1.enterprise_id
AND
jt1.is_delete = 0
WHERE
t1.user_id = #{userId}
</select>
<!-- 获取企业污染因子 -->
<select id="getEnterprisePollution" parameterType="map" resultMap="enterprisePollutionDTO" useCache="true">
SELECT
enterprise_id,
enterprise_type,
pollution_factor,
pollution_factor_dangerous,
pollution_factor_other,
pollution_facilities,
pollution_control_facilities,
eia_status,
check_status,
related_documents
FROM
gen_enterprise_pollution
WHERE
enterprise_id = #{enterpriseId}
</select>
<!-- 获取企业污染因子 -->
<select id="listEnterprisePollution" parameterType="map" resultMap="enterprisePollutionDTO" useCache="true">
SELECT
enterprise_id,
enterprise_type,
pollution_factor,
pollution_factor_dangerous,
pollution_factor_other,
pollution_facilities,
pollution_control_facilities,
eia_status,
check_status,
related_documents
FROM
gen_enterprise_pollution
WHERE
1 = 1
<if test="pollutionFactor != null and pollutionFactor != ''">
AND
pollution_factor LIKE CONCAT('%', #{pollutionFactor}, '%')
</if>
<if test="pollutionFactors != null and pollutionFactors.size > 0">
AND
<foreach collection="pollutionFactors" index="index" open="(" separator="OR" close=")">
pollution_factor LIKE CONCAT('%', #{pollutionFactors[${index}]}, '%')
</foreach>
</if>
<if test="enterpriseId != null and enterpriseId != ''">
AND
enterprise_id = #{enterpriseId}
</if>
<if test="enterpriseIds != null and enterpriseId.size > 0">
AND
enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</if>
</select>
<select id="countEnterprisePollution" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
count(*)
FROM
gen_enterprise_pollution
WHERE
enterprise_type = #{enterpriseType}
</select>
</mapper>