btyjj-inspection/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml
2020-04-14 18:45:30 +08:00

411 lines
14 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">
<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="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="legal_person" property="legalPerson"/>
<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"/>
</resultMap>
<!-- 新增企业 -->
<insert id="saveEnterprise" parameterType="map">
INSERT INTO gen_enterprise(
enterprise_id,
name,
type,
area1,
area2,
area3,
area4,
area5,
address,
industry,
engaged_count,
risk_operation,
master,
phone,
factory_gate,
workplace,
industry_type,
bussiness_reg_num,
legal_person,
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,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{enterpriseId},
#{name},
#{type},
#{area1},
#{area2},
#{area3},
#{area4},
#{area5},
#{address},
#{industry},
#{engagedCount},
#{riskOperation},
#{master},
#{phone},
#{factoryGate},
#{workplace},
#{industryType},
#{bussinessRegNum},
#{legalPerson},
#{summary},
#{typeDictionaryName},
#{area1DictionaryName},
#{area2DictionaryName},
#{area3DictionaryName},
#{area4DictionaryName},
#{area5DictionaryName},
#{industryTypeDictionaryName},
#{industryDictionaryName},
#{riskOperationDictionaryName},
#{classify},
#{classifyDictionaryName},
#{nature},
#{natureDictionaryName},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除企业 -->
<update id="removeEnterprise" parameterType="map">
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">
UPDATE
gen_enterprise
SET
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="type != null and type != ''">
type = #{type},
</if>
<if test="area1 != null and area1 != ''">
area1 = #{area1},
</if>
<if test="area2 != null and area2 != ''">
area2 = #{area2},
</if>
<if test="area3 != null and area3 != ''">
area3 = #{area3},
</if>
<if test="area4 != null and area4 != ''">
area4 = #{area4},
</if>
<if test="area5 != null and area5 != ''">
area5 = #{area5},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
<if test="industry != null and industry != ''">
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="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="factoryGate != null and factoryGate != ''">
factory_gate = #{factoryGate},
</if>
<if test="workplace != null and workplace != ''">
workplace = #{workplace},
</if>
<if test="industryType != null and industryType != ''">
industry_type = #{industryType},
</if>
<if test="bussinessRegNum != null and bussinessRegNum != ''">
bussiness_reg_num = #{bussinessRegNum},
</if>
<if test="legalPerson != null and legalPerson != ''">
legal_person = #{legalPerson},
</if>
<if test="summary != null and summary != ''">
summary = #{summary},
</if>
<if test="typeDictionaryName != null and typeDictionaryName != ''">
type_dictionary_name = #{typeDictionaryName},
</if>
<if test="area1DictionaryName != null and area1DictionaryName != ''">
area1_dictionary_name = #{area1DictionaryName},
</if>
<if test="area2DictionaryName != null and area2DictionaryName != ''">
area2_dictionary_name = #{area2DictionaryName},
</if>
<if test="area3NictionaryName != null and area3NictionaryName != ''">
area3_dictionary_name = #{area3NictionaryName},
</if>
<if test="area4NictionaryName != null and area4NictionaryName != ''">
area4_dictionary_name = #{area4NictionaryName},
</if>
<if test="area5NictionaryName != null and area5NictionaryName != ''">
area5_dictionary_name = #{area5NictionaryName},
</if>
<if test="industryTypeNictionaryName != null and industryTypeNictionaryName != ''">
industry_type_dictionary_name = #{industryTypeNictionaryName},
</if>
<if test="industryNictionaryName != null and industryNictionaryName != ''">
industry_dictionary_name = #{industryNictionaryName},
</if>
<if test="riskOperationNictionaryName != null and riskOperationNictionaryName != ''">
risk_operation_dictionary_name = #{riskOperationNictionaryName},
</if>
<if test="classify != null and classify != ''">
classify = #{classify},
</if>
<if test="classifyDictionaryName != null and classifyDictionaryName != ''">
classify_dictionary_name = #{classifyDictionaryName},
</if>
<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>
<!-- 企业详情 -->
<select id="getEnterprise" parameterType="map" resultMap="enterpriseDTO">
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.phone,
t1.factory_gate,
t1.workplace,
t1.industry_type,
t1.industry_type_dictionary_name,
t1.bussiness_reg_num,
t1.legal_person,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
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">
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.phone,
t1.factory_gate,
t1.workplace,
t1.industry_type,
t1.bussiness_reg_num,
t1.legal_person,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
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">
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.phone,
t1.industry_type,
t1.industry_type_dictionary_name,
t1.bussiness_reg_num,
t1.legal_person,
t1.summary,
t1.classify,
t1.classify_dictionary_name,
t1.nature,
t1.nature_dictionary_name,
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="enterpriseIds != null and enterpriseIds.size > 0">
AND
t1.enterprise_id IN
<foreach collection="enterpriseIds" index="index" open="(" separator="," close=")">
#{enterpriseIds[${index}]}
</foreach>
</if>
</select>
</mapper>