<?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.mobile.modules.biz.repo.mapper.RepoRecordMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
t.record_id as recordId,
|
t.create_time as createTime,
|
t.create_user as createUser,
|
t.repo_id as repoId,
|
t.repo_unit_id as repoUnitId,
|
t.ring_num as ringNum
|
</sql>
|
|
<sql id="condition_query">
|
<where>
|
<trim suffixOverrides=" AND ">
|
<if test="createTime!=null">
|
t.create_time = #{createTime} AND
|
</if>
|
<if test="createUser!=null and createUser!=''">
|
t.create_user = #{createUser} AND
|
</if>
|
<if test="repoId!=null and repoId!=''">
|
t.repo_id = #{repoId} AND
|
</if>
|
<if test="repoUnitId!=null and repoUnitId!=''">
|
t.repo_unit_id = #{repoUnitId} AND
|
</if>
|
<if test="ringNum!=null and ringNum!=''">
|
t.ring_num = #{ringNum} AND
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
<select id="queryById" resultType="com.thhy.mobile.modules.biz.repo.entity.RepoRecord">
|
select <include refid="Base_Column_List" />
|
from t_repo_record t
|
where t.record_id=#{recordId}
|
</select>
|
|
<select id="queryVersionById" resultType="integer">
|
select version from t_repo_record
|
where record_id=#{recordId}
|
</select>
|
|
<!--查询列表-->
|
<select id="findList" resultType="com.thhy.mobile.modules.biz.repo.entity.RepoRecord">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_repo_record t
|
<include refid="condition_query" />
|
</select>
|
|
<!--查询列表-->
|
<select id="findAll" resultType="com.thhy.mobile.modules.biz.repo.entity.RepoRecord">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_repo_record t
|
</select>
|
|
<!--插入操作-->
|
<insert id="insert">
|
insert into t_repo_record
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="recordId != null">
|
record_id,
|
</if>
|
<if test="repoId != null">
|
repo_id,
|
</if>
|
<if test="repoUnitId != null">
|
repo_unit_id,
|
</if>
|
<if test="ringNum != null">
|
ring_num,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="createUser != null">
|
#{createUser},
|
</if>
|
<if test="recordId != null">
|
#{recordId},
|
</if>
|
<if test="repoId != null">
|
#{repoId},
|
</if>
|
<if test="repoUnitId != null">
|
#{repoUnitId},
|
</if>
|
<if test="ringNum != null">
|
#{ringNum},
|
</if>
|
</trim>
|
</insert>
|
|
|
<!--更新操作-->
|
<update id="update">
|
update t_repo_record
|
<set>
|
<if test="createTime != null">
|
create_time=#{createTime},
|
</if>
|
<if test="createUser != null">
|
create_user=#{createUser},
|
</if>
|
<if test="repoId != null">
|
repo_id=#{repoId},
|
</if>
|
<if test="repoUnitId != null">
|
repo_unit_id=#{repoUnitId},
|
</if>
|
<if test="ringNum != null">
|
ring_num=#{ringNum},
|
</if>
|
</set>
|
where record_id=#{recordId}
|
</update>
|
|
<!--逻辑删除-->
|
<update id="deletelogic">
|
update t_repo_record
|
SET is_use = 0
|
where record_id=#{recordId}
|
</update>
|
|
<!--根据ID删除-->
|
<delete id="deleteById">
|
delete from t_repo_record
|
where record_id=#{recordId}
|
</delete>
|
|
<select id="countByRingNum" resultType="int">
|
select count(record_id) from t_repo_record where ring_num = #{ringNum}
|
</select>
|
|
<!--插入操作-->
|
<insert id="insertRecordPipe">
|
insert into t_repo_record_pipe
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
id,
|
</if>
|
<if test="pipeNum != null">
|
pipe_num,
|
</if>
|
<if test="recordId != null">
|
record_id,
|
</if>
|
<if test="ringNum != null">
|
ring_num,
|
</if>
|
<if test="repoId != null">
|
repo_id,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null">
|
#{id},
|
</if>
|
<if test="pipeNum != null">
|
#{pipeNum},
|
</if>
|
<if test="recordId != null">
|
#{recordId},
|
</if>
|
<if test="ringNum != null">
|
#{ringNum},
|
</if>
|
<if test="repoId != null">
|
#{repoId},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="recordList" resultType="com.thhy.mobile.modules.biz.repo.entity.IntoListVo">
|
SELECT a.*,sp.pro_name as proName from
|
(select tpr.record_id as recordId,tpr.ring_num as ringNum,repo.repo_name as repoName,tpr.create_time as createTime,su.real_name as createUser,(select pro_id from t_pipe_info where ring_num = tpr.ring_num limit 1) as proId
|
from t_repo_record tpr
|
left join t_repo repo on tpr.repo_id = repo.repo_id
|
left join sys_users su on su.user_id = tpr.create_user
|
<where>
|
<trim suffixOverrides=" AND ">
|
repo.company_id = #{companyId} AND
|
<if test="repoId !=null and repoId !=''">
|
tpr.repo_id = #{repoId} AND
|
</if>
|
<if test="ringNum !=null and ringNum !=''">
|
tpr.ring_num LIKE concat('%',#{ringNum},'%') AND
|
</if>
|
</trim>
|
</where>
|
) a
|
left join sys_project sp on sp.pro_id = a.proId
|
order by a.createTime desc
|
</select>
|
|
|
|
<select id="countRecordByRepoId" resultType="int">
|
select count(record_id) from t_repo_record where repo_id = #{repoId}
|
</select>
|
|
<select id="countByUnitId" resultType="int">
|
select count(record_id) from t_repo_record where repo_unit_id = #{unitId}
|
</select>
|
|
<select id="repoDetail" resultType="com.thhy.mobile.modules.biz.repo.entity.RepoRecordListVo">
|
select r.repo_name as repoName,ru.unit_name as unitName,rrp.pipe_num as pipeNum,rrp.ring_num as ringNum,
|
sp.pro_name as proName,sd1.dict_name as turnName,sd2.dict_name as sizeName,sd3.dict_name as blockNumName,
|
sd4.dict_name as reinforcementName,sd5.dict_name as groutingHolesName,rr.create_time as createTime,rrp.out_repo_time as outRepoTime,
|
(select SYSDATE() BETWEEN rr.create_time and DATE_ADD(rr.create_time,INTERVAL r.save_time DAY)) as timeOut
|
from t_repo_record_pipe rrp
|
left join t_repo_record rr on rr.record_id = rrp.record_id
|
left join t_repo r on r.repo_id = rr.repo_id
|
left join t_repo_unit ru on ru.unit_id = rr.repo_unit_id
|
left join t_pipe_info tpi on tpi.pipe_num = rrp.pipe_num
|
left join sys_project sp on sp.pro_id = tpi.pro_id
|
left join sys_dict sd1 on sd1.dict_id = tpi.turn
|
left join sys_dict sd2 on sd2.dict_id = tpi.size
|
left join sys_dict sd3 on sd3.dict_id = tpi.block_num
|
left join sys_dict sd4 on sd4.dict_id = tpi.reinforcement
|
left join sys_dict sd5 on sd5.dict_id = tpi.grouting_holes
|
<where>
|
<trim suffixOverrides=" AND ">
|
r.repo_id = #{repoId} AND
|
<if test="ringNum !=null and ringNum !=''">
|
rrp.ring_num LIKE concat('%',#{ringNum},'%') AND
|
</if>
|
<if test="unitId !=null and unitId !=''">
|
ru.unit_id = #{unitId} AND
|
</if>
|
<if test="blockNum !=null and blockNum !=''">
|
tpi.block_num = #{blockNum} AND
|
</if>
|
<if test="reinforcement !=null and reinforcement !=''">
|
tpi.reinforcement = #{reinforcement} AND
|
</if>
|
<if test="groutingHoles !=null and groutingHoles !=''">
|
tpi.grouting_holes = #{groutingHoles} AND
|
</if>
|
<if test="timeOut !=null and timeOut !=''">
|
<if test="timeOut == 1">
|
(SYSDATE() BETWEEN rr.create_time and DATE_ADD(rr.create_time,INTERVAL r.save_time DAY)) AND
|
</if>
|
<if test="timeOut == 2">
|
(sysdate() < rr.create_time or sysdate() > DATE_ADD(rr.create_time,INTERVAL r.save_time DAY)) AND
|
</if>
|
</if>
|
<if test="startTime !=null">
|
rr.create_time > #{startTime} AND
|
</if>
|
<if test="endTime !=null">
|
rr.create_time < #{endTime} AND
|
</if>
|
</trim>
|
</where>
|
</select>
|
|
</mapper>
|