You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

298 lines
15 KiB
XML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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.ruoyi.system.mapper.BaseTyreMapper">
<resultMap type="BaseTyre" id="BaseTyreResult">
<result property="tyreId" column="tyre_id" />
<result property="tyreNo" column="tyre_no" />
<result property="selfNo" column="self_no" />
<result property="tyreEpc" column="tyre_epc" />
<result property="inboundCode" column="inbound_code" />
<result property="tyreBrand" column="tyre_brand" />
<result property="tyreModel" column="tyre_model" />
<result property="tyreLevel" column="tyre_level" />
<result property="tyrePattern" column="tyre_pattern" />
<result property="pressure" column="pressure" />
<result property="tyreType" column="tyre_type" />
<result property="team" column="team" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="carNo" column="car_no" />
<result property="wheelPostion" column="wheel_postion" />
<result property="patternDepth" column="pattern_depth" />
<result property="company" column="company" />
<result property="carTeam" column="carTeam" />
<result property="grooves" column="grooves" />
<result property="inventoryStatus" column="inventory_status" />
</resultMap>
<sql id="selectBaseTyreVo">
select d.tyre_id, d.tyre_no, d.self_no, d.tyre_epc, d.tyre_brand, d.tyre_model, d.tyre_level, d.tyre_pattern,
d.grooves, d.pattern_depth, d.tyre_type, d.team, d.inbound_code, d.inventory_status, d.create_by, d.create_time, d.update_by, d.update_time,
d.remark, d.car_no, d.wheel_postion, d.dept_id, tyre_dept.dept_name,
company_dept.dept_name as company, car_dept.dept_name as carTeam
from base_tyre d
<!-- 详情页与 tyre.html 列表页保持同一口径:公司/车队跟随当前安装车辆,修理厂跟随轮胎档案 team。 -->
left join base_car bc on bc.car_no = d.car_no
left join sys_dept car_dept on car_dept.dept_id = bc.dept_id
left join sys_dept repair_dept on repair_dept.dept_id = car_dept.parent_id
left join sys_dept company_dept on company_dept.dept_id = repair_dept.parent_id
left join sys_dept tyre_dept on tyre_dept.dept_id = d.dept_id
</sql>
<select id="selectBaseTyreList" parameterType="BaseTyre" resultMap="BaseTyreResult">
SELECT
tyre_id,
tyre_no,
self_no,
tyre_epc,
d.inbound_code,
tyre_brand,
tyre_model,
tyre_level,
tyre_pattern,
pattern_depth,
tyre_type,
sdss.dept_name as company,
d.team,
sd.dept_name as carTeam,
su.user_name AS create_by,
d.create_time,
d.update_by,
d.update_time,
d.remark,
d.car_no,
wheel_postion,
d.inventory_status
FROM
base_tyre d
LEFT JOIN sys_user su ON su.login_name = d.create_by
LEFT JOIN base_car bc ON bc.car_no = d.car_no
LEFT JOIN sys_dept sd ON bc.dept_id = sd.dept_id
LEFT JOIN sys_dept sds ON sd.parent_id = sds.dept_id
LEFT JOIN sys_dept sdss ON sds.parent_id = sdss.dept_id
where tyre_id is not null
<if test="tyreNo != null and tyreNo != ''"> and tyre_no like concat('%', #{tyreNo}, '%')</if>
<if test="selfNo != null and selfNo != ''"> and self_no like concat('%', #{selfNo}, '%')</if>
<if test="tyreEpc != null and tyreEpc != ''"> and tyre_epc like concat('%', #{tyreEpc}, '%')</if>
<if test="inboundCode != null and inboundCode != ''"> and d.inbound_code = #{inboundCode}</if>
<if test="tyreBrand != null and tyreBrand != ''"> and tyre_brand like concat('%', #{tyreBrand}, '%')</if>
<if test="tyreModel != null and tyreModel != ''"> and tyre_model = #{tyreModel}</if>
<if test="tyreLevel != null and tyreLevel != ''"> and tyre_level = #{tyreLevel}</if>
<if test="tyrePattern != null and tyrePattern != ''"> and tyre_pattern = #{tyrePattern}</if>
<if test="tyreType != null and tyreType != ''"> and tyre_type = #{tyreType}</if>
<if test="team != null and team != ''"> and d.team like concat('%', #{team}, '%')</if>
<if test="carNo != null and carNo != ''"> and d.car_no = #{carNo}</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(d.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(d.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
<if test="inventoryStatus != null and inventoryStatus != ''">
AND d.inventory_status = #{inventoryStatus}
</if>
${params.dataScope}
</select>
<select id="selectBaseTyreById" parameterType="Long" resultMap="BaseTyreResult">
<include refid="selectBaseTyreVo"/>
where d.tyre_id = #{tyreId}
</select>
<select id="checkTyreNoUnique" parameterType="String" resultType="int">
select count(1) from base_tyre where tyre_no=#{tyreNo}
</select>
<select id="selectBaseTyreByEpc" parameterType="BaseTyre" resultMap="BaseTyreResult">
<include refid="selectBaseTyreVo"/>
<where>
<if test="tyreEpc != null and tyreEpc != ''"> and d.tyre_epc like concat('%', #{tyreEpc}, '%')</if>
</where>
</select>
<select id="getTeamByUser" resultType="java.lang.String">
SELECT
dept_name
FROM
sys_dept sd
LEFT JOIN sys_user su ON su.dept_id = sd.dept_id
WHERE
su.login_name = #{createBy}
</select>
<select id="vTyreStockSummary" resultType="java.util.Map" parameterType="SysDept">
SELECT
IFNULL(v.dept_name, '合计') AS dept_name,
new_count AS '新胎',
circulating_count AS '周转胎',
renovate_count AS '翻新胎',
experimental_count AS '实验胎',
incar AS '在车轮胎'
FROM
v_tyre_stock_summary v
left join sys_dept d on v.dept_name = d.dept_name
<where>
<if test="deptName != null and deptName != ''"> and v.dept_name = #{deptName}</if>
${params.dataScope}
</where>
</select>
<select id="selectBaseTyreByKeyParam" resultMap="BaseTyreResult" parameterType="BaseTyre">
SELECT
tyre_id,
tyre_no,
self_no,
tyre_epc,
tyre_brand,
tyre_model,
tyre_level,
tyre_pattern,
pattern_depth,
tyre_type,
sdss.dept_name as company,
d.team,
sd.dept_name as carTeam,
su.user_name AS create_by,
d.create_time,
d.update_by,
d.update_time,
d.remark,
d.car_no,
wheel_postion,
d.pressure
FROM
base_tyre d
LEFT JOIN sys_user su ON su.login_name = d.create_by
LEFT JOIN base_car bc ON bc.car_no = d.car_no
LEFT JOIN sys_dept sd ON bc.dept_id = sd.dept_id
LEFT JOIN sys_dept sds ON sd.parent_id = sds.dept_id
LEFT JOIN sys_dept sdss ON sds.parent_id = sdss.dept_id
<where>
<choose>
<when test="tyreId != null">d.tyre_id = #{tyreId}</when>
<when test="keyParam != null and keyParam != ''">
<!-- tyreId 用于后台详情抽屉keyParam 保留给 PDA 按 EPC/胎号/自编号查询,避免两端走出不同生命周期口径。 -->
(d.tyre_epc = #{keyParam} OR d.tyre_no = #{keyParam} OR d.self_no = #{keyParam})
</when>
<otherwise>
1 = 0
</otherwise>
</choose>
</where>
</select>
<insert id="insertBaseTyre" parameterType="BaseTyre">
insert into base_tyre
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tyreId != null ">tyre_id,</if>
<if test="tyreNo != null and tyreNo != ''">tyre_no,</if>
<if test="selfNo != null and selfNo != ''">self_no,</if>
<if test="tyreEpc != null and tyreEpc != ''">tyre_epc,</if>
<if test="inboundCode != null and inboundCode != ''">inbound_code,</if>
<if test="tyreBrand != null and tyreBrand != ''">tyre_brand,</if>
<if test="tyreModel != null and tyreModel != ''">tyre_model,</if>
<if test="tyreLevel != null and tyreLevel != ''">tyre_level,</if>
<if test="tyrePattern != null and tyrePattern != ''">tyre_pattern,</if>
<if test="grooves != null and grooves != ''">grooves,</if>
<if test="tyreType != null and tyreType != ''">tyre_type,</if>
<if test="team != null and team != ''">team,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null ">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null ">update_time,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="deptId != null and deptId != ''">dept_id,</if>
<if test="patternDepth != null and patternDepth != ''">pattern_depth,</if>
<if test="inventoryStatus != null and inventoryStatus != ''">inventory_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tyreId != null ">#{tyreId},</if>
<if test="tyreNo != null and tyreNo != ''">#{tyreNo},</if>
<if test="selfNo != null and selfNo != ''">#{selfNo},</if>
<if test="tyreEpc != null and tyreEpc != ''">#{tyreEpc},</if>
<if test="inboundCode != null and inboundCode != ''">#{inboundCode},</if>
<if test="tyreBrand != null and tyreBrand != ''">#{tyreBrand},</if>
<if test="tyreModel != null and tyreModel != ''">#{tyreModel},</if>
<if test="tyreLevel != null and tyreLevel != ''">#{tyreLevel},</if>
<if test="tyrePattern != null and tyrePattern != ''">#{tyrePattern},</if>
<if test="grooves != null and grooves != ''">#{grooves},</if>
<if test="tyreType != null and tyreType != ''">#{tyreType},</if>
<if test="team != null and team != ''">#{team},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null ">#{updateTime},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="patternDepth != null and patternDepth != ''">#{patternDepth},</if>
<if test="inventoryStatus != null and inventoryStatus != ''">#{inventoryStatus},</if>
</trim>
</insert>
<update id="updateBaseTyre" parameterType="BaseTyre">
update base_tyre
<trim prefix="SET" suffixOverrides=",">
<if test="tyreNo != null and tyreNo != ''">tyre_no = #{tyreNo},</if>
<if test="selfNo != null and selfNo != ''">self_no = #{selfNo},</if>
<if test="tyreEpc != null and tyreEpc != ''">tyre_epc = #{tyreEpc},</if>
<if test="inboundCode != null and inboundCode != ''">inbound_code = #{inboundCode},</if>
<if test="tyreBrand != null and tyreBrand != ''">tyre_brand = #{tyreBrand},</if>
<if test="tyreModel != null and tyreModel != ''">tyre_model = #{tyreModel},</if>
<if test="tyreLevel != null and tyreLevel != ''">tyre_level = #{tyreLevel},</if>
<if test="tyrePattern != null and tyrePattern != ''">tyre_pattern = #{tyrePattern},</if>
<if test="tyreType != null and tyreType != ''">tyre_type = #{tyreType},</if>
<if test="team != null and team != ''">team = #{team},</if>
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null ">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null ">update_time = #{updateTime},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="carNo != null ">car_no = #{carNo},</if>
<if test="wheelPostion != null ">wheel_postion = #{wheelPostion},</if>
<if test="inventoryStatus != null">inventory_status = #{inventoryStatus},</if>
</trim>
where tyre_id = #{tyreId}
</update>
<update id="updateBaseTyreByEpc" parameterType="BaseTyre">
update base_tyre
<trim prefix="SET" suffixOverrides=",">
<if test="team != null and team != ''">team = #{team},</if>
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
</trim>
where tyre_epc = #{tyreEpc}
</update>
<delete id="deleteBaseTyreById" parameterType="Long">
delete from base_tyre where tyre_id = #{tyreId}
</delete>
<delete id="deleteBaseTyreByIds" parameterType="String">
delete from base_tyre where tyre_id in
<foreach item="tyreId" collection="array" open="(" separator="," close=")">
#{tyreId}
</foreach>
</delete>
<select id="selectByInboundCode" resultMap="BaseTyreResult">
<include refid="selectBaseTyreVo"/>
where d.inbound_code = #{inboundCode}
and d.tyre_epc is not null
and d.tyre_epc &lt;&gt; ''
order by d.tyre_id
</select>
<select id="countBaseTyreByInboundCode" resultType="int">
select count(1)
from base_tyre
where inbound_code = #{inboundCode}
</select>
</mapper>