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.

233 lines
12 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.ruoyi.system.mapper.BizMaintenanceOrderMapper">
<resultMap type="BizMaintenanceOrder" id="BizMaintenanceOrderResult">
<result property="orderId" column="order_id" />
<result property="orderNo" column="order_no" />
<result property="vehicleId" column="vehicle_id" />
<result property="plateNumber" column="plate_number" />
<result property="typeCode" column="type_code" />
<result property="factoryId" column="factory_id" />
<result property="factoryName" column="factoryName" />
<result property="inputMileage" column="input_mileage" />
<result property="lastMileage" column="last_mileage" />
<result property="maintainDate" column="maintain_date" />
<result property="description" column="description" />
<result property="status" column="status" />
<result property="orderType" column="order_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="userName" column="user_name" />
<result property="updateName" column="update_name" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="line" column="line" />
</resultMap>
<sql id="selectBizMaintenanceOrderVo">
select order_id, order_no, vehicle_id, plate_number, type_code, factory_id, input_mileage, last_mileage, maintain_date, description, status, order_type, create_by, create_time, update_by, update_time, remark from biz_maintenance_order
</sql>
<select id="selectBizMaintenanceOrderList" parameterType="BizMaintenanceOrder" resultMap="BizMaintenanceOrderResult">
<include refid="selectBizMaintenanceOrderVo"/>
<where>
<if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
<if test="vehicleId != null "> and vehicle_id = #{vehicleId}</if>
<if test="plateNumber != null and plateNumber != ''"> and plate_number = #{plateNumber}</if>
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
<if test="factoryId != null "> and factory_id = #{factoryId}</if>
<if test="inputMileage != null "> and input_mileage = #{inputMileage}</if>
<if test="lastMileage != null "> and last_mileage = #{lastMileage}</if>
<if test="maintainDate != null "> and maintain_date = #{maintainDate}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
<if test="params.beginTime != null and params.beginTime != ''">
and date_format(maintain_date,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
and date_format(maintain_date,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
</where>
</select>
<select id="selectBizMaintenanceOrderListTwo" parameterType="BizMaintenanceOrder" resultMap="BizMaintenanceOrderResult">
select order_id, order_no, vehicle_id, plate_number, type_code, factory_id, d.dept_name as factoryName, input_mileage, last_mileage, maintain_date, description, bmo.status, order_type,
bmo.create_by,su.user_name, bmo.create_time, bmo.update_by,sus.user_name as update_name, bmo.update_time, bmo.remark
from biz_maintenance_order bmo
left join sys_user su ON su.login_name = bmo.create_by
left join sys_user sus ON sus.login_name = bmo.update_by
left join sys_dept d on bmo.factory_id = d.dept_id
<where>
<if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
<if test="vehicleId != null "> and vehicle_id = #{vehicleId}</if>
<if test="plateNumber != null and plateNumber != ''"> and plate_number = #{plateNumber}</if>
<if test="typeCode == null or typeCode == ''"> and type_code in ('1','4')</if>
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
<if test="factoryId != null "> and factory_id = #{factoryId}</if>
<if test="inputMileage != null "> and input_mileage = #{inputMileage}</if>
<if test="lastMileage != null "> and last_mileage = #{lastMileage}</if>
<if test="maintainDate != null "> and maintain_date = #{maintainDate}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="status != null and status != ''"> and bmo.status = #{status}</if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
<if test="params.beginTime != null and params.beginTime != ''">
and date_format(maintain_date,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
and date_format(maintain_date,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
${params.dataScope}
</where>
</select>
<select id="selectBizMaintenanceOrderByOrderId" parameterType="Long" resultMap="BizMaintenanceOrderResult">
SELECT
order_id,
order_no,
vehicle_id,
plate_number,
type_code,
sd.dept_name as factoryName,
input_mileage,
last_mileage,
maintain_date,
description,
bmo.`STATUS`,
order_type,
su.user_name as create_by,
bmo.create_time,
sus.user_name as update_by,
bmo.update_time,
bmo.remark,
bc.line
FROM
biz_maintenance_order bmo
LEFT JOIN sys_dept sd ON bmo.factory_id = sd.dept_id
LEFT JOIN sys_user su ON su.login_name = bmo.create_by
LEFT JOIN sys_user sus ON sus.login_name = bmo.update_by
LEFT JOIN base_car bc ON bc.id = bmo.vehicle_id
where order_id = #{orderId}
</select>
<select id="selectBizMaintenanceOrderTD" resultMap="BizMaintenanceOrderResult">
SELECT
MAX(order_no) as order_no
FROM
biz_maintenance_order
WHERE
DATE(create_time) = CURDATE();
</select>
<select id="selectBizMaintenanceOrderByOrderIdBefore"
resultMap="BizMaintenanceOrderResult" parameterType="BizMaintenanceOrder">
SELECT
order_id,
order_no,
vehicle_id,
plate_number,
type_code,
sd.dept_name as factoryName,
input_mileage,
last_mileage,
maintain_date,
description,
bmo.`STATUS`,
order_type,
su.user_name as create_by,
bmo.create_time,
sus.user_name as update_by,
bmo.update_time,
bmo.remark,
bc.line
FROM
biz_maintenance_order bmo
LEFT JOIN sys_dept sd ON bmo.factory_id = sd.dept_id
LEFT JOIN sys_user su ON su.login_name = bmo.create_by
LEFT JOIN sys_user sus ON sus.login_name = bmo.update_by
LEFT JOIN base_car bc ON bc.id = bmo.vehicle_id
WHERE
bmo.order_id != #{orderId}
AND bmo.plate_number = #{plateNumber}
ORDER BY
bmo.create_time DESC -- 关键点1按照维保日期倒序排列最近的时间在前
LIMIT 1; -- 关键点2只取第一条数据
</select>
<insert id="insertBizMaintenanceOrder" parameterType="BizMaintenanceOrder" useGeneratedKeys="true" keyProperty="orderId">
insert into biz_maintenance_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no,</if>
<if test="vehicleId != null">vehicle_id,</if>
<if test="plateNumber != null">plate_number,</if>
<if test="typeCode != null and typeCode != ''">type_code,</if>
<if test="factoryId != null">factory_id,</if>
<if test="inputMileage != null">input_mileage,</if>
<if test="lastMileage != null">last_mileage,</if>
<if test="maintainDate != null">maintain_date,</if>
<if test="description != null">description,</if>
<if test="status != null">status,</if>
<if test="orderType != null">order_type,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
<if test="vehicleId != null">#{vehicleId},</if>
<if test="plateNumber != null">#{plateNumber},</if>
<if test="typeCode != null and typeCode != ''">#{typeCode},</if>
<if test="factoryId != null">#{factoryId},</if>
<if test="inputMileage != null">#{inputMileage},</if>
<if test="lastMileage != null">#{lastMileage},</if>
<if test="maintainDate != null">#{maintainDate},</if>
<if test="description != null">#{description},</if>
<if test="status != null">#{status},</if>
<if test="orderType != null">#{orderType},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBizMaintenanceOrder" parameterType="BizMaintenanceOrder">
update biz_maintenance_order
<trim prefix="SET" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
<if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
<if test="plateNumber != null">plate_number = #{plateNumber},</if>
<if test="typeCode != null and typeCode != ''">type_code = #{typeCode},</if>
<if test="factoryId != null">factory_id = #{factoryId},</if>
<if test="inputMileage != null">input_mileage = #{inputMileage},</if>
<if test="lastMileage != null">last_mileage = #{lastMileage},</if>
<if test="maintainDate != null">maintain_date = #{maintainDate},</if>
<if test="description != null">description = #{description},</if>
<if test="status != null">status = #{status},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where order_id = #{orderId}
</update>
<delete id="deleteBizMaintenanceOrderByOrderId" parameterType="Long">
delete from biz_maintenance_order where order_id = #{orderId}
</delete>
<delete id="deleteBizMaintenanceOrderByOrderIds" parameterType="String">
delete from biz_maintenance_order where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
</mapper>