lanan-system/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml

148 lines
6.0 KiB
XML
Raw Normal View History

2024-08-01 17:24:41 +08:00
<?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="cn.iocoder.yudao.module.custom.mapper.CarMainMapper">
2024-08-02 18:31:12 +08:00
<sql id="baseCarMainColumn">
tbcm.id,
tbcm.engine_number,
tbcm.vin,
tbcm.license_number,
tbcm.car_model,
tbcm.maintenance_date,
tbcm.maintenance_mileage,
tbcm.inspection_date,
tbcm.insurance_date,
tbcm.check_date,
tbcm.next_maintenance_date,
tbcm.next_maintenance_mileage,
tbcm.next_inspection_date,
tbcm.insurance_expiry_date,
tbcm.next_check_date,
tbcm.car_brand,
tbcm.car_nature,
tbcm.car_category,
tbcm.car_register_date,
tbcm.car_license_img,
tbcm.recently_handled_business,
tbcm.recently_handle_business_time,
tbcm.deleted,
tbcm.creator,
tbcm.create_time,
tbcm.updater,
tbcm.update_time
2024-08-01 17:24:41 +08:00
</sql>
<select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
2024-08-08 10:56:21 +08:00
<include refid="baseCarMainColumn"></include>,
bcb.brand_name AS brandStr,
bcm.model_name AS modelStr
FROM
`base_car_main` tbcm
LEFT JOIN base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id
LEFT JOIN base_car_model bcm ON bcm.deleted = 0 AND tbcm.car_model = bcm.id
2024-08-01 17:24:41 +08:00
WHERE
2024-08-02 18:31:12 +08:00
tbcm.deleted = 0
2024-08-01 17:24:41 +08:00
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.license_number LIKE CONCAT('%',#{dto.licenseNumber},'%')
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.carBrand != null and dto.carBrand != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.car_brand = #{dto.carBrand}
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.carCategory != null and dto.carCategory != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.car_category = #{dto.carCategory}
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.recently_handled_business = #{dto.recentlyHandledBusiness}
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.recentlyHandleBusinessTime != null">
2024-08-02 18:31:12 +08:00
AND tbcm.recently_handle_business_time = #{dto.recentlyHandleBusinessTime}
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.vin != null and dto.vin != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.vin LIKE CONCAT('%',#{dto.vin},'%')
2024-08-01 17:24:41 +08:00
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
2024-08-02 18:31:12 +08:00
AND tbcm.tenant_id = #{dto.tenant}
</if>
<if test="dto.carModel != null and dto.carModel != ''">
AND tbcm.car_model = #{dto.carModel}
</if>
<if test="dto.carNature != null and dto.carNature != ''">
AND tbcm.car_nature = #{dto.carNature}
</if>
<if test="dto.engineNumber != null and dto.engineNumber != ''">
AND tbcm.engine_number LIKE CONCAT('%',#{dto.engineNumber},'%')
</if>
ORDER BY
tbcm.car_register_date DESC
</select>
2024-08-08 10:56:21 +08:00
<select id="findOne" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="baseCarMainColumn"></include>,
bcb.brand_name AS brandStr,
bcm.model_name AS modelStr
FROM
`base_car_main` tbcm
LEFT JOIN base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id
LEFT JOIN base_car_model bcm ON bcm.deleted = 0 AND tbcm.car_model = bcm.id
WHERE
tbcm.deleted = 0
AND
tbcm.id = #{id}
</select>
2024-08-02 18:31:12 +08:00
<select id="isDataKeyValueRepeat" resultType="cn.iocoder.yudao.module.custom.entity.CarMain">
SELECT
tbcm.id
FROM `base_car_main` tbcm
WHERE
tbcm.deleted = 0
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
AND tbcm.license_number = #{dto.licenseNumber}
</if>
<if test="dto.vin != null and dto.vin != ''">
AND tbcm.vin = #{dto.vin}
</if>
<if test="dto.engineNumber != null and dto.engineNumber != ''">
AND tbcm.engine_number = #{dto.engineNumber}
2024-08-01 17:24:41 +08:00
</if>
</select>
2024-08-14 16:25:30 +08:00
<select id="remindCarMainPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="baseCarMainColumn"></include>,
bcc.is_owner AS isOwner,
bcm.cus_name AS cusName,
bcm.phone_number AS phoneNumber,
bcb.brand_name AS brandStr,
bcmm.model_name AS modelStr,
DATEDIFF(tbcm.next_inspection_date, CURDATE()) AS njCont,
DATEDIFF(tbcm.next_maintenance_date, CURDATE()) AS byCont,
DATEDIFF(tbcm.insurance_expiry_date, CURDATE()) AS bxCont
FROM
base_car_main tbcm
LEFT JOIN base_customer_car bcc ON tbcm.id = bcc.car_id AND bcc.deleted = 0
LEFT JOIN base_customer_main bcm ON bcc.cus_id = bcm.id AND bcm.deleted = 0
LEFT JOIN base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id
LEFT JOIN base_car_model bcmm ON bcmm.deleted = 0 AND tbcm.car_model = bcmm.id
WHERE
tbcm.deleted = 0
<if test="entity.licenseNumber != null and entity.licenseNumber != ''">
AND tbcm.license_number LIKE CONCAT('%',#{entity.licenseNumber},'%')
</if>
<if test="entity.cusName != null and entity.cusName != ''">
AND bcm.cus_name LIKE CONCAT('%',#{entity.cusName},'%')
</if>
<if test="entity.selectSign == '01'">
AND tbcm.next_inspection_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 3 MONTH)
</if>
<if test="entity.selectSign == '02'">
AND tbcm.next_maintenance_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH)
</if>
<if test="entity.selectSign == '03'">
AND tbcm.insurance_expiry_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 45 DAY)
</if>
</select>
2024-08-01 17:24:41 +08:00
</mapper>