299 lines
9.2 KiB
XML
299 lines
9.2 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" 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"/>
|
|
</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,
|
|
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},
|
|
#{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>
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
enterprise_id = #{enterpriseId}
|
|
</update>
|
|
|
|
<!-- 企业详情 -->
|
|
<select id="getEnterprise" parameterType="map" resultMap="enterpriseDTO">
|
|
SELECT
|
|
t1.name,
|
|
t1.type,
|
|
t1.area1,
|
|
t1.area2,
|
|
t1.area3,
|
|
t1.area4,
|
|
t1.area5,
|
|
t1.address,
|
|
t1.industry,
|
|
t1.engaged_count,
|
|
t1.risk_operation,
|
|
t1.master,
|
|
t1.phone,
|
|
t1.factory_gate,
|
|
t1.workplace,
|
|
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,
|
|
dt1.dictionary_name type_dictionary_name,
|
|
t1.area1,
|
|
dt4.dictionary_name area1_dictionary_name,
|
|
t1.area2,
|
|
dt5.dictionary_name area2_dictionary_name,
|
|
t1.area3,
|
|
dt6.dictionary_name area3_dictionary_name,
|
|
t1.area4,
|
|
dt7.dictionary_name area4_dictionary_name,
|
|
t1.area5,
|
|
dt8.dictionary_name area5_dictionary_name,
|
|
t1.address,
|
|
t1.industry,
|
|
dt2.dictionary_name industry_dictionary_name,
|
|
t1.engaged_count,
|
|
t1.risk_operation,
|
|
dt3.dictionary_name risk_operation_dictionary_name,
|
|
t1.master,
|
|
t1.phone,
|
|
t1.enterprise_id
|
|
FROM
|
|
gen_enterprise t1
|
|
LEFT JOIN
|
|
data_dictionary dt1
|
|
ON
|
|
dt1.dictionary_id = t1.type
|
|
AND
|
|
dt1.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt2
|
|
ON
|
|
dt2.dictionary_id = t1.industry
|
|
AND
|
|
dt2.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt3
|
|
ON
|
|
dt3.dictionary_id = t1.risk_operation
|
|
AND
|
|
dt3.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt4
|
|
ON
|
|
dt4.dictionary_id = t1.area1
|
|
AND
|
|
dt4.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt5
|
|
ON
|
|
dt5.dictionary_id = t1.area2
|
|
AND
|
|
dt5.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt6
|
|
ON
|
|
dt6.dictionary_id = t1.area3
|
|
AND
|
|
dt6.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt7
|
|
ON
|
|
dt7.dictionary_id = t1.area4
|
|
AND
|
|
dt7.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt8
|
|
ON
|
|
dt8.dictionary_id = t1.area5
|
|
AND
|
|
dt8.is_delete = 0
|
|
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> |