<?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.materials.modules.biz.pipeout.mapper.TPipeOutMapper">
|
<resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.pipeout.entity.TPipeOut">
|
<!--
|
WARNING - @mbg.generated
|
This element is automatically generated by MyBatis Generator, do not modify.
|
This element was generated on Thu May 18 10:48:54 CST 2023.
|
-->
|
<id column="pipe_out_id" jdbcType="VARCHAR" property="pipeOutId" />
|
<result column="pro_id" jdbcType="VARCHAR" property="proId" />
|
<result column="car_id" jdbcType="VARCHAR" property="carId" />
|
<result column="in_user_id" jdbcType="VARCHAR" property="inUserId" />
|
<result column="str_time" jdbcType="TIMESTAMP" property="strTime" />
|
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
|
<result column="notes" jdbcType="VARCHAR" property="notes" />
|
<result column="is_use" jdbcType="INTEGER" property="isUse" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
<result column="out_user_id" jdbcType="VARCHAR" property="outUserId" />
|
</resultMap>
|
|
|
<insert id="pipeOutInsert">
|
insert into t_pipe_out
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="pipeOutId != null">
|
pipe_out_id,
|
</if>
|
<if test="proId != null">
|
pro_id,
|
</if>
|
<if test="carId != null">
|
car_id,
|
</if>
|
<if test="inUserId != null">
|
in_user_id,
|
</if>
|
<if test="strTime != null">
|
str_time,
|
</if>
|
<if test="endTime != null">
|
end_time,
|
</if>
|
<if test="notes != null">
|
notes,
|
</if>
|
<if test="isUse != null">
|
is_use,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="createUser != null">
|
create_user,
|
</if>
|
<if test="outUserId != null">
|
out_user_id,
|
</if>
|
<if test="gdId != null">
|
gd_id,
|
</if>
|
<if test="pipeOutNumber != null">
|
pipe_out_number,
|
</if>
|
<if test="companyId != null">
|
company_id,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="pipeOutId != null">
|
#{pipeOutId,jdbcType=VARCHAR},
|
</if>
|
<if test="proId != null">
|
#{proId,jdbcType=VARCHAR},
|
</if>
|
<if test="carId != null">
|
#{carId,jdbcType=VARCHAR},
|
</if>
|
<if test="inUserId != null">
|
#{inUserId,jdbcType=VARCHAR},
|
</if>
|
<if test="strTime != null">
|
#{strTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="endTime != null">
|
#{endTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="notes != null">
|
#{notes,jdbcType=VARCHAR},
|
</if>
|
<if test="isUse != null">
|
#{isUse,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
#{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="outUserId != null">
|
#{outUserId,jdbcType=VARCHAR},
|
</if>
|
<if test="gdId != null">
|
#{gdId,jdbcType=VARCHAR},
|
</if>
|
<if test="pipeOutNumber != null">
|
#{pipeOutNumber},
|
</if>
|
<if test="companyId != null">
|
#{companyId},
|
</if>
|
</trim>
|
</insert>
|
|
<insert id="pipeOutPipeInsert">
|
insert into t_pipe_out_pipe
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="pipeOutId != null">
|
pipe_out_id,
|
</if>
|
<if test="pipeId != null">
|
pipe_id,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="pipeOutId != null">
|
#{pipeOutId,jdbcType=VARCHAR},
|
</if>
|
<if test="pipeId != null">
|
#{pipeId,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="pipeOutList" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeOut">
|
SELECT
|
tpo.pipe_out_id AS pipeOutId,
|
tpo.pro_id AS proId,
|
tpo.car_id AS carId,
|
tpo.in_user_id AS inUserId,
|
tpo.str_time AS strTime,
|
tpo.end_time AS endTime,
|
tpo.notes AS notes,
|
tpo.out_user_id AS outUserId,
|
sc.car_brand AS carBrand,
|
sc.car_driver AS carDriver,
|
sc.car_phone AS carPhone,
|
sr.reciver_name AS reciverName,
|
sr.reciver_phone AS reciverPhone,
|
su.real_name AS realName,
|
sd.dict_name as carTypeName,
|
tpo.create_time as createTime,
|
sp.pro_name as proName,
|
sr.reciver_unit as reciverUnit
|
FROM
|
t_pipe_out tpo
|
LEFT JOIN sys_car sc ON tpo.car_id = sc.car_id
|
LEFT JOIN sys_reciver sr ON tpo.in_user_id = sr.id
|
LEFT JOIN sys_users su ON tpo.out_user_id = su.user_id
|
left join sys_dict sd on sc.car_type=sd.dict_id
|
left join t_pipe_out_pipe tpop on tpo.pipe_out_id=tpop.pipe_out_id
|
left join t_pipe_info tpi on tpop.pipe_id=tpi.pipe_id
|
left join t_repo_record_pipe rrp on tpi.pipe_num=rrp.pipe_num
|
left join sys_project sp on tpo.pro_id=sp.pro_id
|
where tpo.is_use=1
|
<if test="proId!=null and proId!='' ">
|
and tpo.pro_id=#{proId}
|
</if>
|
<if test="carBrand!=null and carBrand!='' ">
|
and sc.car_brand like concat('%',#{carBrand},'%')
|
</if>
|
<if test="companyId!=null and companyId!='' ">
|
and sc.company_id=#{companyId}
|
</if>
|
<if test="ringNum!=null and ringNum!='' ">
|
and tpi.ring_num like concat('%',#{ringNum},'%')
|
</if>
|
<if test="pipeNum!=null and pipeNum!='' ">
|
and tpi.pipe_num like concat('%',#{pipeNum},'%')
|
</if>
|
<if test="repoId!=null and repoId!='' ">
|
and rrp.repo_id like concat('%',#{repoId},'%')
|
</if>
|
GROUP BY tpo.pipe_out_id
|
order by tpo.create_time desc
|
</select>
|
<select id="pipeOutInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeOut">
|
SELECT
|
tpo.pipe_out_id AS pipeOutId,
|
tpo.pro_id AS proId,
|
tpo.car_id AS carId,
|
tpo.in_user_id AS inUserId,
|
tpo.str_time AS strTime,
|
tpo.end_time AS endTime,
|
tpo.notes AS notes,
|
tpo.out_user_id AS outUserId,
|
sc.car_brand AS carBrand,
|
sc.car_driver AS carDriver,
|
sc.car_phone AS carPhone,
|
sr.reciver_name AS reciverName,
|
sr.reciver_phone AS reciverPhone,
|
tpo.out_user_id AS outUserId,
|
su.real_name AS realName,
|
tpo.gd_id as gdId,
|
sp.pro_name as proName,
|
concat(gd.gd_name,':',gd.gd_imei) as gdName,
|
scc.company_name AS companyName,
|
tpo.pipe_out_number as pipeOutNumber,
|
sr.reciver_unit as reciverUnit
|
FROM
|
t_pipe_out tpo
|
LEFT JOIN sys_car sc ON tpo.car_id = sc.car_id
|
LEFT JOIN sys_reciver sr ON tpo.in_user_id = sr.id
|
LEFT JOIN sys_users su ON tpo.out_user_id = su.user_id
|
LEFT JOIN t_gps_device gd ON gd.gd_id = tpo.gd_id
|
left join sys_project sp on tpo.pro_id=sp.pro_id
|
LEFT JOIN sys_company scc ON scc.company_id = sp.company_id
|
where tpo.is_use=1 and tpo.pipe_out_id=#{pipeOutId}
|
</select>
|
|
|
<update id="pipeInfoUpdate" >
|
update t_pipe_info set
|
go_in=2,
|
out_repo_time=#{format1}
|
where pipe_id=#{pipeId}
|
</update>
|
|
<select id="pipeOutPipeInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeInfo">
|
SELECT
|
tpi.ring_num as ringNum,
|
tpi.pipe_num as pipeNum,
|
tpi.pipe_id as pipeId,
|
tpi.block_num as blockNum,
|
sd.dict_name AS sizeName,
|
sd1.dict_name AS reinforcementName,
|
sd2.dict_name AS blockNumName,
|
sd3.dict_name AS turnName
|
FROM
|
t_pipe_out_pipe tpop
|
LEFT JOIN t_pipe_info tpi ON tpop.pipe_id = tpi.pipe_id
|
LEFT JOIN sys_dict sd ON tpi.size = sd.dict_id
|
LEFT JOIN sys_dict sd1 ON tpi.reinforcement = sd1.dict_id
|
LEFT JOIN sys_dict sd2 ON tpi.block_num = sd2.dict_id
|
LEFT JOIN sys_dict sd3 ON tpi.turn = sd3.dict_id
|
where tpop.pipe_out_id=#{pipeOutId}
|
</select>
|
<select id="pipeSelectPipeId" parameterType="java.lang.String" resultType="java.lang.String">
|
select pipe_id as pipeId from t_pipe_out_pipe tpop
|
where pipe_out_id=#{pipeOutId}
|
</select>
|
<update id="pipeInfoUpIn" parameterType="java.lang.String">
|
update t_pipe_info set
|
go_in=1,
|
out_repo_time=null
|
where pipe_id=#{pipeId}
|
</update>
|
<delete id="pipeOutPipeDel" parameterType="java.lang.String">
|
delete from t_pipe_out_pipe where pipe_out_id=#{pipeOutId}
|
</delete>
|
<update id="pipeOutDel" parameterType="java.lang.String">
|
update t_pipe_out set
|
is_use=2
|
where pipe_out_id=#{pipeOutId}
|
</update>
|
<update id="pipeOutUpdate" >
|
update t_pipe_out
|
<set>
|
<if test="proId != null">
|
pro_id = #{proId,jdbcType=VARCHAR},
|
</if>
|
<if test="carId != null">
|
car_id = #{carId,jdbcType=VARCHAR},
|
</if>
|
<if test="inUserId != null">
|
in_user_id = #{inUserId,jdbcType=VARCHAR},
|
</if>
|
<if test="strTime != null">
|
str_time = #{strTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="endTime != null">
|
end_time = #{endTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="notes != null">
|
notes = #{notes,jdbcType=VARCHAR},
|
</if>
|
<if test="isUse != null">
|
is_use = #{isUse,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="createUser != null">
|
create_user = #{createUser,jdbcType=VARCHAR},
|
</if>
|
<if test="outUserId != null">
|
out_user_id = #{outUserId,jdbcType=VARCHAR},
|
</if>
|
<if test="gdId != null">
|
gd_id = #{gdId,jdbcType=VARCHAR},
|
</if>
|
</set>
|
where pipe_out_id = #{pipeOutId,jdbcType=VARCHAR}
|
</update>
|
<select id="pipeOutCheck" parameterType="java.lang.String" resultType="java.lang.String">
|
select go_in from t_pipe_info where check_result=1 and pipe_num=#{pipeNum}
|
</select>
|
|
<select id="pipeInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeInfo">
|
SELECT
|
tpi.ring_num AS ringNum,
|
tpi.pipe_num AS pipeNum,
|
sp.pro_name as proName,
|
sd.dict_name as sizeName,
|
sd1.dict_name as blockNumName,
|
tpi.pipe_id as pipeId
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
left join sys_dict sd on tpi.size=sd.dict_id
|
left join sys_dict sd1 on tpi.block_num=sd1.dict_id
|
where tpi.pipe_num=#{pipeNum}
|
</select>
|
|
|
<select id="pipeOutShippingSum" resultType="java.lang.String">
|
SELECT
|
count( tpi.pipe_id )
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
WHERE
|
tpi.go_in = 2
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
<if test="strTime!=null and endTime!=null and strTime!='' and endTime!='' ">
|
and tpi.out_repo_time between #{strTime} and #{endTime}
|
</if>
|
<if test="proId!=null and proId!='' ">
|
and sp.pro_id=#{proId}
|
</if>
|
</select>
|
<select id="pipeOutTransportSum" resultType="java.lang.String">
|
SELECT
|
count( tpi.pipe_id )
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
WHERE
|
tpi.go_in = 2
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
<if test="strTime!=null and endTime!=null and strTime!='' and endTime!='' ">
|
and tpi.out_repo_time between #{strTime} and #{endTime}
|
</if>
|
<if test="proId!=null and proId!='' ">
|
and sp.pro_id=#{proId}
|
</if>
|
</select>
|
<select id="pipeOutCarSum" resultType="java.lang.String">
|
SELECT
|
COUNT( pipe_out_id )
|
FROM
|
(
|
SELECT
|
pop.pipe_out_id
|
FROM
|
t_pipe_out_pipe pop
|
LEFT JOIN t_pipe_info tpi ON pop.pipe_id = tpi.pipe_id
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
WHERE
|
tpi.go_in = 2
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
<if test="strTime!=null and endTime!=null and strTime!='' and endTime!='' ">
|
and tpi.out_repo_time between #{strTime} and #{endTime}
|
</if>
|
GROUP BY
|
pop.pipe_out_id
|
) s
|
</select>
|
<select id="pipeOutProduceSum" resultType="java.lang.String">
|
SELECT
|
COUNT( pipe_id )
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
WHERE
|
tpi.check_result = 1
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
<if test="strTime!=null and endTime!=null and strTime!='' and endTime!='' ">
|
and tpi.check_time between #{strTime} and #{endTime}
|
</if>
|
<if test="proId!=null and proId!='' ">
|
and sp.pro_id=#{proId}
|
</if>
|
</select>
|
<select id="pipeOutRanking" resultType="com.thhy.materials.modules.biz.pipeout.entity.dto.RanKingDto">
|
select
|
sps.pro_id,
|
sps.pro_name,
|
sps.sizeName,
|
sps.blockName,
|
sps.sizes,
|
IF(sps.produce!='' or sps.produce!=null ,sps.produce,0) as produce,
|
IF(a.goIn!='' or a.goIn!=null ,a.goIn,0) as goIn
|
from (SELECT
|
sp.pro_id,
|
sp.pro_name,
|
sp.sizeName,
|
sp.blockName,
|
sp.sizes,
|
sp.block_num,
|
IF(b.produce!='' or b.produce!=null ,b.produce,0) as produce
|
FROM
|
(
|
SELECT
|
a.pro_id,
|
a.pro_name,
|
a.sizes,
|
spb.block_num,
|
a.dict_name AS sizeName,
|
sd1.dict_name AS blockName
|
FROM
|
(
|
SELECT
|
sp.pro_id,
|
sp.pro_name,
|
sps.sizes,
|
sd.dict_name
|
FROM
|
sys_project sp
|
LEFT JOIN sys_pro_sizes sps ON sp.pro_id = sps.pro_id
|
LEFT JOIN sys_dict sd ON sps.sizes = sd.dict_id
|
WHERE
|
sp.is_use = 1
|
) a
|
LEFT JOIN sys_pro_blok spb ON a.pro_id = spb.pro_id
|
LEFT JOIN sys_dict sd1 ON spb.block_num = sd1.dict_id
|
) sp
|
left join
|
(
|
SELECT
|
tpi.pro_id,
|
sp.pro_name,
|
tpi.size,
|
tpi.block_num,
|
sd.dict_name AS sizeName,
|
sd1.dict_name AS blockName,
|
COUNT( tpi.pro_id ) AS produce
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
LEFT JOIN sys_dict sd ON tpi.size = sd.dict_id
|
LEFT JOIN sys_dict sd1 ON tpi.block_num = sd1.dict_id
|
WHERE
|
tpi.check_result = 1
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and tpi.check_time between #{strTime} and #{endTime}
|
</if>
|
GROUP BY
|
tpi.pro_id,
|
tpi.size,
|
tpi.block_num
|
ORDER BY
|
COUNT( tpi.pro_id ) DESC
|
) b on sp.pro_id=b.pro_id and sp.sizes=b.size and b.block_num=sp.block_num
|
|
) sps
|
|
left join (
|
SELECT
|
tpi.pro_id,
|
tpi.size,
|
tpi.block_num,
|
COUNT( tpi.pro_id ) AS goIn
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
WHERE
|
tpi.go_in = 2
|
<if test="strTime!=null and strTime!='' and endTime!=null and endTime!='' ">
|
and tpi.out_repo_time between #{strTime} and #{endTime}
|
</if>
|
GROUP BY
|
tpi.pro_id,
|
tpi.size,
|
tpi.block_num
|
ORDER BY
|
COUNT( tpi.pro_id ) DESC
|
) a on sps.pro_id=a.pro_id and sps.sizes=a.size and sps.block_num=a.block_num
|
where 1=1
|
<if test="proId!=null and proId!='' ">
|
and sps.pro_id=#{proId}
|
</if>
|
<if test="sizes!=null and sizes!='' ">
|
and sps.sizes=#{sizes}
|
</if>
|
order by a.goIn desc
|
</select>
|
|
<select id="projectSize" resultType="com.thhy.materials.modules.biz.pipeout.entity.dto.ProjectSizeDto">
|
SELECT
|
sp.pro_id as proId,
|
sps.sizes as sizes
|
FROM
|
sys_project sp
|
LEFT JOIN sys_pro_sizes sps ON sp.pro_id = sps.pro_id
|
where sp.is_use=1
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id=#{companyId}
|
</if>
|
<if test="proId!=null and proId!='' ">
|
and sp.pro_id=#{proId}
|
</if>
|
</select>
|
<select id="pipeOutGps" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeOutPosition">
|
select voyage_longitude as voyageLongitude,voyage_latitude as voyageLatitude from t_pipe_out_position
|
where pipr_out_id=#{piprOutId}
|
</select>
|
<insert id="pipePathInsert" >
|
insert into t_pipe_out_path
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="pipeOutId != null">
|
pipe_out_id,
|
</if>
|
<if test="outPath != null">
|
out_path,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="pipeOutId != null">
|
#{pipeOutId,jdbcType=VARCHAR},
|
</if>
|
<if test="outPath != null">
|
#{outPath,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
|
<delete id="pipeOutImgDel" parameterType="java.lang.String">
|
delete from t_pipe_out_path
|
where pipe_out_id=#{pipeOutId}
|
</delete>
|
|
<select id="pipeOutImgInfo" parameterType="java.lang.String" resultType="com.thhy.materials.modules.biz.pipeout.entity.TPipeOutPath">
|
select out_path as outPath,
|
pipe_out_id as pipeOutId
|
from t_pipe_out_path where pipe_out_id=#{pipeOutId}
|
|
</select>
|
|
<update id="updateRepoRecord">
|
update t_repo_record_pipe set out_repo = 1 and out_repo_time = sysdate() where pipe_num = #{pipeNum}
|
</update>
|
|
<select id="queryPipeNumByPipeId" resultType="string">
|
select pipe_num from t_pipe_info where pipe_id = #{pipeId}
|
</select>
|
<select id="pipeInfoInList" resultType="com.thhy.materials.modules.biz.pipeout.entity.dto.PipeInfoDto">
|
SELECT
|
tpi.pipe_id as pipeId,
|
tpi.ring_num as ringNum,
|
tpi.pipe_num as pipeNum,
|
sd.dict_name AS sizeName,
|
sd1.dict_name AS reinforcementName,
|
sd2.dict_name AS blockNumName
|
FROM
|
t_pipe_info tpi
|
LEFT JOIN sys_project sp ON tpi.pro_id = sp.pro_id
|
LEFT JOIN sys_dict sd ON tpi.size = sd.dict_id
|
LEFT JOIN sys_dict sd1 ON tpi.reinforcement = sd1.dict_id
|
LEFT JOIN sys_dict sd2 ON tpi.block_num = sd2.dict_id
|
WHERE
|
tpi.go_in = '1'
|
<if test="companyId!=null and companyId!='' ">
|
and sp.company_id =#{companyId}
|
</if>
|
<if test="ringNum!=null and ringNum!='' ">
|
and tpi.ring_num like concat('%',#{ringNum},'%')
|
</if>
|
|
</select>
|
|
<select id="pipeOutNew" resultType="java.lang.String">
|
select pipe_out_number from t_pipe_out where is_use=1
|
and company_id=#{companyId}
|
and pipe_out_number like concat('%',#{dates},'%')
|
order by create_time desc limit 0,1
|
</select>
|
|
</mapper>
|