<?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.thhy.secure.modules.biz.regionInspection.mapper.RegionInspectionRecordMapper">
|
|
<insert id="insertIMG">
|
insert into t_region_inspection_record
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="regionInspectionRecordId != null">
|
regionInspectionRecordId,
|
</if>
|
<if test="imgName != null">
|
imgName,
|
</if>
|
<if test="imgPath != null">
|
imgPath,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="regionInspectionRecordId != null">
|
#{regionInspectionRecordId,jdbcType=VARCHAR},
|
</if>
|
<if test="imgName != null">
|
#{imgName,jdbcType=VARCHAR},
|
</if>
|
<if test="imgPath != null">
|
#{imgPath,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
<insert id="insert">
|
insert into t_region_inspection_record
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="regionInspectionId != null">
|
regionInspectionId,
|
</if>
|
<if test="userId != null">
|
userId,
|
</if>
|
<if test="regionHazardInformId != null">
|
regionHazardInformId,
|
</if>
|
<if test="status != null">
|
`status`,
|
</if>
|
<if test="location != null">
|
location,
|
</if>
|
<if test="inspectionTime != null">
|
inspectionTime,
|
</if>
|
<if test="createUser != null">
|
createUser,
|
</if>
|
<if test="createTime != null">
|
createTime,
|
</if>
|
<if test="updateUser != null">
|
updateUser,
|
</if>
|
<if test="updateTime != null">
|
updateTime,
|
</if>
|
<if test="result != null">
|
result,
|
</if>
|
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="regionInspectionId != null">
|
#{regionInspectionId,jdbcType=VARCHAR},
|
</if>
|
<if test="userId != null">
|
#{userId,jdbcType=VARCHAR},
|
</if>
|
<if test="regionHazardInformId != null">
|
#{regionHazardInformId,jdbcType=VARCHAR},
|
</if>
|
<if test="status != null">
|
#{status,jdbcType=INTEGER},
|
</if>
|
<if test="location != null">
|
#{location,jdbcType=VARCHAR},
|
</if>
|
<if test="inspectionTime != null">
|
#{inspectionTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
#{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateUser != null">
|
#{updateUser,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="result != null">
|
#{result,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
on duplicate key update
|
<trim suffixOverrides=",">
|
<if test="regionInspectionId != null">
|
regionInspectionId = #{regionInspectionId,jdbcType=VARCHAR},
|
</if>
|
<if test="userId != null">
|
userId = #{userId,jdbcType=VARCHAR},
|
</if>
|
<if test="regionHazardInformId != null">
|
regionHazardInformId = #{regionHazardInformId,jdbcType=VARCHAR},
|
</if>
|
<if test="status != null">
|
`status` = #{status,jdbcType=INTEGER},
|
</if>
|
<if test="location != null">
|
location = #{location,jdbcType=VARCHAR},
|
</if>
|
<if test="inspectionTime != null">
|
inspectionTime = #{inspectionTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
createUser = #{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateUser != null">
|
updateUser = #{updateUser,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="result != null">
|
result = #{result,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
|
<delete id="delete">
|
delete from t_region_inspection_record where id=#{id,jdbcType=VARCHAR}
|
</delete>
|
|
<delete id="deleteByRegionInspectionId">
|
delete from t_region_inspection_record where regionInspectionId=#{regionInspectionId,jdbcType=VARCHAR}
|
</delete>
|
|
<select id="selectPageList" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionRecordEntity">
|
SELECT a.userId,
|
a.regionInspectionId,
|
a.inspectionTime,
|
a.task,
|
a.region,
|
a.realName,
|
IF(a.completeRegionNum = a.needRegionNum,"已完成","待巡检") statusName,
|
IF(a.completeRegionNum = a.needRegionNum,1,0) status
|
FROM (
|
SELECT
|
t.userId ,
|
t.regionInspectionId,
|
MIN(t.inspectionTime) inspectionTime,
|
tri.task task,
|
GROUP_CONCAT(DISTINCT trhi.region) region,
|
spu.real_name realName,
|
SUM(t.`status`)/(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId = t.regionInspectionId) completeRegionNum,
|
(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId = t.regionInspectionId) needRegionNum
|
from
|
t_region_inspection_record t
|
LEFT JOIN t_region_inspection tri on tri.id = t.regionInspectionId
|
LEFT JOIN t_region_inspection_hazard_inform trihi on trihi.regionInspectionId = t.regionInspectionId
|
LEFT JOIN t_region_hazard_inform trhi on trhi.id = trihi.regionHazardInformId
|
LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
|
WHERE 1=1
|
<if test="realName !=null and realName !=''">
|
and spu.real_name REGEXP #{realName}
|
</if>
|
<if test="companyId !=null and companyId !=''">
|
and tri.companyId = #{companyId}
|
</if>
|
<if test="regionInspectionId !=null and regionInspectionId !=''">
|
and t.regionInspectionId = #{regionInspectionId}
|
</if>
|
<if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
|
and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime}, "%Y-%m-%d %H:%i:%s")
|
</if>
|
GROUP BY t.regionInspectionId,t.userId
|
)a
|
WHERE 1=1
|
<if test="intStatus!=null and intStatus ==0">
|
and a.completeRegionNum != a.needRegionNum
|
</if>
|
<if test="intStatus!=null and intStatus ==1">
|
and a.completeRegionNum = a.needRegionNum
|
</if>
|
<if test="page != null and limit != null">
|
limit #{page},#{limit}
|
</if>
|
</select>
|
<select id="selectCount" resultType="java.lang.Integer">
|
SELECT count(0)
|
FROM (
|
SELECT
|
t.userId ,
|
t.regionInspectionId,
|
MIN(t.inspectionTime) inspectionTime,
|
tri.task task,
|
GROUP_CONCAT(DISTINCT trhi.region) region,
|
spu.real_name realName,
|
SUM(t.`status`)/(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId = t.regionInspectionId) completeRegionNum,
|
(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId = t.regionInspectionId) needRegionNum
|
from
|
t_region_inspection_record t
|
LEFT JOIN t_region_inspection tri on tri.id = t.regionInspectionId
|
LEFT JOIN t_region_inspection_hazard_inform trihi on trihi.regionInspectionId = t.regionInspectionId
|
LEFT JOIN t_region_hazard_inform trhi on trhi.id = trihi.regionHazardInformId
|
LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
|
WHERE 1=1
|
<if test="realName !=null and realName !=''">
|
and spu.real_name REGEXP #{realName}
|
</if>
|
<if test="companyId !=null and companyId !=''">
|
and tri.companyId = #{companyId}
|
</if>
|
<if test="regionInspectionId !=null and regionInspectionId !=''">
|
and t.regionInspectionId = #{regionInspectionId}
|
</if>
|
<if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
|
and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime}, "%Y-%m-%d %H:%i:%s")
|
</if>
|
GROUP BY t.regionInspectionId,t.userId
|
)a
|
WHERE 1=1
|
<if test="intStatus!=null and intStatus ==0">
|
and a.completeRegionNum != a.needRegionNum
|
</if>
|
<if test="intStatus!=null and intStatus ==1">
|
and a.completeRegionNum = a.needRegionNum
|
</if>
|
</select>
|
<select id="selectInfo" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionEntity">
|
SELECT
|
t.id regionInspectionId,
|
b.user_id userId,
|
t.task,
|
t.standard,
|
b.real_name realName,
|
GROUP_CONCAT(DISTINCT d.region ORDER BY c.sort SEPARATOR ',') regions,
|
GROUP_CONCAT(DISTINCT d.id ORDER BY c.sort SEPARATOR ',') regionIds
|
FROM t_region_inspection t
|
LEFT JOIN t_region_inspection_user a ON a.regionInspectionId = t.id
|
LEFT JOIN sys_plat_user b ON b.user_id = a.userId
|
LEFT JOIN t_region_inspection_hazard_inform c ON c.regionInspectionId = t.id
|
LEFT JOIN t_region_hazard_inform d ON d.id = c.regionHazardInformId
|
WHERE t.id = #{regionInspectionId} and b.user_id = #{userId}
|
GROUP BY t.id
|
</select>
|
|
<select id="regionInfo" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionRecordEntity">
|
SELECT
|
t.userId,
|
t.regionInspectionId,
|
t.regionHazardInformId,
|
t.inspectionTime inspectionTime,
|
rhi.region region,
|
t.result result,
|
GROUP_CONCAT(timg.imgPath) imgPaths,
|
t.location,
|
spu.real_name realName
|
FROM t_region_inspection_record t
|
LEFT JOIN t_region_inspection_record_img timg on t.id = timg.regionInspectionRecordId
|
LEFT JOIN t_region_hazard_inform rhi on rhi.id = t.regionHazardInformId
|
LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
|
WHERE t.userId = #{userId} and t.regionInspectionId = #{regionInspectionId} and t.regionHazardInformId = #{regionHazardInformId}
|
GROUP BY t.id
|
</select>
|
|
<select id="selectAppList" resultType="java.util.Map">
|
SELECT
|
a.id,
|
MIN( b.inspectionTime ) inspectionTime,
|
a.`status`,
|
a.task,
|
GROUP_CONCAT(DISTINCT d.region) region
|
FROM
|
t_region_inspection a
|
LEFT JOIN t_region_inspection_record b ON b.regionInspectionId = a.id
|
LEFT JOIN t_region_inspection_hazard_inform c ON c.regionInspectionId = a.id
|
LEFT JOIN t_region_hazard_inform d ON c.regionHazardInformId = d.id
|
LEFT JOIN t_region_inspection_user e on e.regionInspectionId = a.id
|
WHERE a.companyId = #{companyId} and e.userId = #{userId}
|
<if test="status != null and status != ''">
|
and a.status = #{status}
|
</if>
|
<if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
|
and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime}, "%Y-%m-%d %H:%i:%s")
|
</if>
|
GROUP BY
|
a.id
|
</select>
|
|
</mapper>
|