416 lines
14 KiB
XML
416 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.check.ICheckDao">
|
|
|
|
<resultMap id="checkDTO" type="com.cm.inspection.pojo.dtos.check.CheckDTO">
|
|
<id column="check_id" property="checkId"/>
|
|
<result column="enterprise_id" property="enterpriseId"/>
|
|
<result column="name_join_by_enterprise_id" property="nameJoinByEnterpriseId"/>
|
|
<result column="type_join_by_enterprise_id" property="typeJoinByEnterpriseId"/>
|
|
<result column="type_dictionary_name" property="typeDictionaryName"/>
|
|
<result column="area1_join_by_enterprise_id" property="area1JoinByEnterpriseId"/>
|
|
<result column="area2_join_by_enterprise_id" property="area2JoinByEnterpriseId"/>
|
|
<result column="area3_join_by_enterprise_id" property="area3JoinByEnterpriseId"/>
|
|
<result column="area4_join_by_enterprise_id" property="area4JoinByEnterpriseId"/>
|
|
<result column="area5_join_by_enterprise_id" property="area5JoinByEnterpriseId"/>
|
|
<result column="address_join_by_enterprise_id" property="addressJoinByEnterpriseId"/>
|
|
<result column="industry_join_by_enterprise_id" property="industryJoinByEnterpriseId"/>
|
|
<result column="industry_dictionary_name" property="industryDictionaryName"/>
|
|
<result column="engaged_count_join_by_enterprise_id" property="engagedCountJoinByEnterpriseId"/>
|
|
<result column="risk_operation_join_by_enterprise_id" property="riskOperationJoinByEnterpriseId"/>
|
|
<result column="risk_operation_dictionary_name" property="riskOperationDictionaryName"/>
|
|
<result column="master_join_by_enterprise_id" property="masterJoinByEnterpriseId"/>
|
|
<result column="phone_join_by_enterprise_id" property="phoneJoinByEnterpriseId"/>
|
|
<result column="enterprise_lng_by_enterprise_id" property="enterpriseLngByEnterpriseId"/>
|
|
<result column="enterprise_lat_by_enterprise_id" property="enterpriseLatByEnterpriseId"/>
|
|
<result column="factory_gate_by_enterprise_id" property="factoryGateByEnterpriseId"/>
|
|
<result column="workplace_by_enterprise_id" property="workplaceByEnterpriseId"/>
|
|
<result column="check_type" property="checkType"/>
|
|
<result column="task_check_id" property="taskCheckId"/>
|
|
<result column="rectification_type" property="rectificationType"/>
|
|
<result column="immediately_change_type" property="immediatelyChangeType"/>
|
|
<result column="rectification_days" property="rectificationDays"/>
|
|
<result column="summary" property="summary"/>
|
|
<result column="is_coordination" property="isCoordination"/>
|
|
<result column="gmt_create" property="gmtCreate"/>
|
|
<result column="is_complete" property="isComplete"/>
|
|
<result column="check_lng" property="checkLng"/>
|
|
<result column="check_lat" property="checkLat"/>
|
|
</resultMap>
|
|
|
|
<!-- 新增检查表 -->
|
|
<insert id="saveCheck" parameterType="map">
|
|
INSERT INTO gen_check(
|
|
check_id,
|
|
enterprise_id,
|
|
check_type,
|
|
task_check_id,
|
|
is_coordination,
|
|
is_complete,
|
|
rectification_type,
|
|
immediately_change_type,
|
|
rectification_days,
|
|
summary,
|
|
check_lng,
|
|
check_lat,
|
|
creator,
|
|
gmt_create,
|
|
modifier,
|
|
gmt_modified,
|
|
is_delete
|
|
) VALUES(
|
|
#{checkId},
|
|
#{enterpriseId},
|
|
#{checkType},
|
|
#{taskCheckId},
|
|
#{isCoordination},
|
|
#{isComplete},
|
|
#{rectificationType},
|
|
#{immediatelyChangeType},
|
|
#{rectificationDays},
|
|
#{summary},
|
|
#{checkLng},
|
|
#{checkLat},
|
|
#{creator},
|
|
#{gmtCreate},
|
|
#{modifier},
|
|
#{gmtModified},
|
|
#{isDelete}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 删除检查表 -->
|
|
<update id="removeCheck" parameterType="map">
|
|
UPDATE
|
|
gen_check
|
|
SET
|
|
is_delete = 1,
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
check_id IN
|
|
<foreach collection="checkIds" index="index" open="(" separator="," close=")">
|
|
#{checkIds[${index}]}
|
|
</foreach>
|
|
</update>
|
|
|
|
<!-- 修改检查表 -->
|
|
<update id="updateCheck" parameterType="map">
|
|
UPDATE
|
|
gen_check
|
|
SET
|
|
<if test="enterpriseId != null and enterpriseId != ''">
|
|
enterprise_id = #{enterpriseId},
|
|
</if>
|
|
<if test="checkType != null">
|
|
check_type = #{checkType},
|
|
</if>
|
|
<if test="taskCheckId != null and taskCheckId != ''">
|
|
task_check_id = #{taskCheckId},
|
|
</if>
|
|
<if test="isCoordination != null">
|
|
is_coordination = #{isCoordination},
|
|
</if>
|
|
<if test="isComplete != null">
|
|
is_complete = #{isComplete},
|
|
</if>
|
|
<if test="rectificationType != null">
|
|
rectification_type = #{rectificationType},
|
|
</if>
|
|
<if test="immediatelyChangeType != null">
|
|
immediately_change_type = #{immediatelyChangeType},
|
|
</if>
|
|
<if test="rectificationDays != null">
|
|
rectification_days = #{rectificationDays},
|
|
</if>
|
|
<if test="summary != null">
|
|
summary = #{summary},
|
|
</if>
|
|
<if test="checkLng != null">
|
|
check_lng = #{checkLng},
|
|
</if>
|
|
<if test="checkLat != null">
|
|
check_lat = #{checkLat},
|
|
</if>
|
|
modifier = #{modifier},
|
|
gmt_modified = #{gmtModified}
|
|
WHERE
|
|
check_id = #{checkId}
|
|
</update>
|
|
|
|
<!-- 检查表详情 -->
|
|
<select id="getCheck" parameterType="map" resultMap="checkDTO">
|
|
SELECT
|
|
t1.enterprise_id,
|
|
jt1.name name_join_by_enterprise_id,
|
|
t1.check_type,
|
|
t1.task_check_id,
|
|
t1.is_coordination,
|
|
t1.is_complete,
|
|
t1.rectification_type,
|
|
t1.immediately_change_type,
|
|
t1.rectification_days,
|
|
t1.summary,
|
|
t1.check_lng,
|
|
t1.check_lat,
|
|
LEFT(t1.gmt_create, 19) gmt_create,
|
|
t1.check_id
|
|
FROM
|
|
gen_check t1
|
|
INNER JOIN
|
|
gen_enterprise jt1
|
|
ON
|
|
t1.enterprise_id = jt1.enterprise_id
|
|
AND
|
|
jt1.is_delete = 0
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="checkId != null and checkId != ''">
|
|
AND
|
|
t1.check_id = #{checkId}
|
|
</if>
|
|
ORDER BY
|
|
t1.gmt_create DESC
|
|
</select>
|
|
|
|
<!-- 检查表列表 -->
|
|
<select id="listCheck" parameterType="map" resultMap="checkDTO">
|
|
SELECT
|
|
t1.enterprise_id,
|
|
jt1.name name_join_by_enterprise_id,
|
|
jt1.type type_join_by_enterprise_id,
|
|
dt1.dictionary_name type_dictionary_name,
|
|
jt1.area1 area1_join_by_enterprise_id,
|
|
jt1.area2 area2_join_by_enterprise_id,
|
|
jt1.area3 area3_join_by_enterprise_id,
|
|
jt1.area4 area4_join_by_enterprise_id,
|
|
jt1.area5 area5_join_by_enterprise_id,
|
|
jt1.address address_join_by_enterprise_id,
|
|
jt1.industry industry_join_by_enterprise_id,
|
|
dt2.dictionary_name industry_dictionary_name,
|
|
jt1.engaged_count engaged_count_join_by_enterprise_id,
|
|
jt1.risk_operation risk_operation_join_by_enterprise_id,
|
|
dt3.dictionary_name risk_operation_dictionary_name,
|
|
jt1.master master_join_by_enterprise_id,
|
|
jt1.phone phone_join_by_enterprise_id,
|
|
jt1.enterprise_lng enterprise_lng_by_enterprise_id,
|
|
jt1.enterprise_lat enterprise_lat_by_enterprise_id,
|
|
jt1.factory_gate factory_gate_by_enterprise_id,
|
|
jt1.workplace workplace_by_enterprise_id,
|
|
t1.check_type,
|
|
t1.task_check_id,
|
|
t1.is_coordination,
|
|
t1.is_complete,
|
|
t1.rectification_type,
|
|
t1.immediately_change_type,
|
|
t1.rectification_days,
|
|
t1.summary,
|
|
t1.check_lng,
|
|
t1.check_lat,
|
|
LEFT(t1.gmt_create, 19) gmt_create,
|
|
t1.check_id
|
|
FROM
|
|
gen_check t1
|
|
INNER JOIN
|
|
gen_enterprise jt1
|
|
ON
|
|
t1.enterprise_id = jt1.enterprise_id
|
|
AND
|
|
jt1.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt1
|
|
ON
|
|
dt1.dictionary_id = jt1.type
|
|
AND
|
|
dt1.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt2
|
|
ON
|
|
dt2.dictionary_id = jt1.industry
|
|
AND
|
|
dt2.is_delete = 0
|
|
LEFT JOIN
|
|
data_dictionary dt3
|
|
ON
|
|
dt3.dictionary_id = jt1.risk_operation
|
|
AND
|
|
dt3.is_delete = 0
|
|
WHERE
|
|
t1.is_delete = 0
|
|
<if test="keywords != null and keywords != ''">
|
|
AND
|
|
jt1.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
|
|
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>
|
|
<if test="type != null and type != ''">
|
|
AND
|
|
jt1.type = #{type}
|
|
</if>
|
|
<if test="industry != null and industry != ''">
|
|
AND
|
|
jt1.industry = #{industry}
|
|
</if>
|
|
<if test="checkType != null and checkType != ''">
|
|
AND
|
|
t1.check_type = #{checkType}
|
|
</if>
|
|
<if test="isCoordination != null and isCoordination != ''">
|
|
AND
|
|
t1.is_coordination = #{isCoordination}
|
|
</if>
|
|
<if test="isComplete != null and isComplete != ''">
|
|
AND
|
|
t1.is_complete = #{isComplete}
|
|
</if>
|
|
<if test="checkIds != null and checkIds.size > 0">
|
|
AND
|
|
t1.check_id IN
|
|
<foreach collection="checkIds" index="index" open="(" separator="," close=")">
|
|
#{checkIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
<if test="creator != null and creator != ''">
|
|
AND
|
|
t1.creator = #{creator}
|
|
</if>
|
|
<if test="checkMonth != null">
|
|
AND
|
|
LEFT(t1.gmt_create, 7) = #{checkMonth}
|
|
</if>
|
|
ORDER BY
|
|
t1.gmt_create DESC
|
|
</select>
|
|
|
|
<!-- 统计检查 -->
|
|
<select id="countCheck" parameterType="map" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
gen_check
|
|
WHERE
|
|
is_delete = 0
|
|
<if test="enterpriseId != null and enterpriseId != ''">
|
|
AND
|
|
enterprise_id = #{enterpriseId}
|
|
</if>
|
|
<if test="creator != null and creator != ''">
|
|
AND
|
|
creator = #{creator}
|
|
</if>
|
|
<if test="taskCheckId != null and taskCheckId != ''">
|
|
AND
|
|
task_check_id = #{taskCheckId}
|
|
</if>
|
|
<if test="rectificationType != null">
|
|
<if test="rectificationType == 0">
|
|
AND (
|
|
is_complete = 0
|
|
OR
|
|
creator != modifier
|
|
)
|
|
</if>
|
|
<if test="rectificationType == 1">
|
|
AND (
|
|
is_complete = 1
|
|
AND
|
|
creator = modifier
|
|
)
|
|
</if>
|
|
</if>
|
|
<if test="checkType != null">
|
|
AND
|
|
check_type = #{checkType}
|
|
</if>
|
|
<if test="isCoordination != null">
|
|
AND
|
|
is_coordination = #{isCoordination}
|
|
</if>
|
|
<if test="isComplete != null and isComplete != ''">
|
|
AND
|
|
is_complete = #{isComplete}
|
|
</if>
|
|
<if test="checkDay != null and checkDay != ''">
|
|
AND
|
|
LEFT(gmt_create, 10) = #{checkDay}
|
|
</if>
|
|
<if test="checkMonth != null and checkMonth != ''">
|
|
AND
|
|
LEFT(gmt_create, 7) = #{checkMonth}
|
|
</if>
|
|
<if test="startDate != null and startDate != ''">
|
|
AND
|
|
LEFT(gmt_create, 7) <![CDATA[ >= ]]> #{startDate}
|
|
</if>
|
|
<if test="endDate != null and endDate != ''">
|
|
AND
|
|
LEFT(gmt_create, 7) <![CDATA[ <= ]]> #{endDate}
|
|
</if>
|
|
<if test="year != null and year != ''">
|
|
AND
|
|
LEFT(gmt_create, 4) = #{year}
|
|
</if>
|
|
<if test="userIdList != null">
|
|
AND
|
|
creator IN
|
|
<foreach collection="userIdList" index="index" open="(" separator="," close=")">
|
|
#{userIdList[${index}]}
|
|
</foreach>
|
|
</if>
|
|
<if test="checkIdList != null and checkIdList.size > 0">
|
|
AND
|
|
check_id IN
|
|
<foreach collection="checkIdList" index="index" open="(" separator="," close=")">
|
|
#{checkIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 检查列表(简单格式) -->
|
|
<select id="listCheckSimple" parameterType="map" resultMap="checkDTO">
|
|
SELECT
|
|
*
|
|
FROM
|
|
gen_check
|
|
WHERE
|
|
is_delete = 0
|
|
<if test="year != null and year != ''">
|
|
AND
|
|
LEFT(gmt_create, 4) = #{year}
|
|
</if>
|
|
<if test="checkIdList != null and checkIdList.size > 0">
|
|
AND
|
|
check_id IN
|
|
<foreach collection="checkIdList" index="index" open="(" separator="," close=")">
|
|
#{checkIds[${index}]}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
</mapper> |