integrated_traffic_scheduled/src/main/resources/mybatis/datasource/traffic/InspectAnnuallyMapper.xml

263 lines
7.0 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.zcloud.mapper.datasource.traffic.InspectAnnuallyMapper">
<!--表名 -->
<sql id="tableName">
BUS_TRAFFIC_MECHANICAL_INSPECT_ANNUALLY
</sql>
<!-- 字段 -->
<sql id="Field">
INSPECTANNUALLY_ID,
CORPINFO_ID,
NUM,
VEHICLE_MODEL,
VEHICLE,
CAR_OWNERS,
TELEPHONE,
REGISTRANT,
PROCESSING_DATE,
ANNUAL_INSPECTION_CYCLE,
DUE_DATE,
INSPECTFEES,
ACTUAL_COLLECTION,
ADDRESS,
REMINDER_DAYS,
REMINDER_DATE,
REMINDER_STATUS,
INSPECTINFO,
NOTES,
ARCHIVES_TYPE,
ISDELETE,
CREATOR,
CREATORNAME,
CREATTIME
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{INSPECTANNUALLY_ID},
#{CORPINFO_ID},
#{NUM},
#{VEHICLE_MODEL},
#{VEHICLE},
#{CAR_OWNERS},
#{TELEPHONE},
#{REGISTRANT},
#{PROCESSING_DATE},
#{ANNUAL_INSPECTION_CYCLE},
#{DUE_DATE},
#{INSPECTFEES},
#{ACTUAL_COLLECTION},
#{ADDRESS},
#{REMINDER_DAYS},
#{REMINDER_DATE},
#{REMINDER_STATUS},
#{INSPECTINFO},
#{NOTES},
#{ARCHIVES_TYPE},
#{ISDELETE},
#{CREATOR},
#{CREATORNAME},
#{CREATTIME}
</sql>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1',
DELETEOR = #{DELETEOR},
DELETEORNAME = #{DELETEORNAME},
DELETTIME = #{DELETTIME}
where
INSPECTANNUALLY_ID = #{INSPECTANNUALLY_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
NUM = #{NUM},
VEHICLE_MODEL = #{VEHICLE_MODEL},
VEHICLE = #{VEHICLE},
CAR_OWNERS = #{CAR_OWNERS},
TELEPHONE = #{TELEPHONE},
REGISTRANT = #{REGISTRANT},
PROCESSING_DATE = #{PROCESSING_DATE},
ANNUAL_INSPECTION_CYCLE = #{ANNUAL_INSPECTION_CYCLE},
DUE_DATE = #{DUE_DATE},
INSPECTFEES = #{INSPECTFEES},
ACTUAL_COLLECTION = #{ACTUAL_COLLECTION},
ADDRESS = #{ADDRESS},
REMINDER_DAYS = #{REMINDER_DAYS},
REMINDER_DATE = #{REMINDER_DATE},
REMINDER_STATUS = #{REMINDER_STATUS},
INSPECTINFO = #{INSPECTINFO},
NOTES = #{NOTES},
ARCHIVES_TYPE = #{ARCHIVES_TYPE},
OPERATOR = #{OPERATOR},
OPERATORNAME = #{OPERATORNAME},
OPERATTIME = #{OPERATTIME}
where
INSPECTANNUALLY_ID = #{INSPECTANNUALLY_ID}
</update>
<!-- 修改 -->
<update id="edit2" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="REMINDER_STATUS != null">
REMINDER_STATUS = #{REMINDER_STATUS},
</if>
OPERATOR = #{OPERATOR},
OPERATORNAME = #{OPERATORNAME},
OPERATTIME = #{OPERATTIME}
where
INSPECTANNUALLY_ID = #{INSPECTANNUALLY_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
f.INSPECTANNUALLY_ID,
f.CORPINFO_ID,
f.NUM,
f.VEHICLE_MODEL,
f.VEHICLE,
f.CAR_OWNERS,
f.TELEPHONE,
f.REGISTRANT,
f.PROCESSING_DATE,
f.ANNUAL_INSPECTION_CYCLE,
f.DUE_DATE,
f.INSPECTFEES,
f.ACTUAL_COLLECTION,
f.ADDRESS,
f.REMINDER_DAYS,
f.REMINDER_DATE,
f.REMINDER_STATUS,
f.INSPECTINFO,
f.NOTES,
f.ARCHIVES_TYPE,
f.ISDELETE,
f.CREATOR,
f.CREATORNAME,
f.CREATTIME,
(SELECT sd.NAME FROM sys_dictionaries sd where sd.DICTIONARIES_ID=f.ANNUAL_INSPECTION_CYCLE) as ANNUAL_INSPECTION_CYCLE_NAME,
v.COMPANY_AREA as AREA
from
<include refid="tableName"></include> f
left join v_traffic v on f.VEHICLE = v.ID
where
f.INSPECTANNUALLY_ID = #{INSPECTANNUALLY_ID}
</select>
<!-- 列表
BASICINFO_LICENSE_PLATE 车牌号
CAR_OWNERS 车主业户
REGISTRANT 登记人
DUE_DATE 到期日期
VEHICLE_MODEL 营运车型
REMINDER_STATUS 提醒状态
-->
<select id="datalistPage" parameterType="page" resultType="pd">
select
b.NAME,
f.*,
case when f.DUE_DATE &lt; NOW() then 0 else 1 end as DUE_DATE_TYPE,
v1.PLATE_NUMBER
from
<include refid="tableName"></include> f
left join sys_dictionaries b on f.ANNUAL_INSPECTION_CYCLE = b.DICTIONARIES_ID AND b.PARENT_ID = '8b7dea3977fd4360a3cc8112368b90ff'
INNER JOIN v_traffic v1 on f.VEHICLE = v1.ID
LEFT JOIN bus_traffic_operatingvehicle bto on bto.OPERATING_ID = f.VEHICLE
LEFT JOIN bus_traffic_mechanical_freighttrailer btmf on btmf.FREIGHTTRAILER_ID = f.VEHICLE
where f.ISDELETE = '0' and f.CORPINFO_ID = #{pd.CORPINFO_ID} and (bto.ISSCRAP = '0' OR btmf.ISSCRAP = '0')
<if test="pd.PLATE_NUMBER != null and pd.PLATE_NUMBER != ''">
and v1.PLATE_NUMBER LIKE CONCAT(CONCAT('%', #{pd.PLATE_NUMBER}),'%')
</if>
<if test="pd.CAR_OWNERS != null and pd.CAR_OWNERS != ''">
and f.CAR_OWNERS LIKE CONCAT(CONCAT('%', #{pd.CAR_OWNERS}),'%')
</if>
<if test="pd.REGISTRANT != null and pd.REGISTRANT != ''">
and f.REGISTRANT LIKE CONCAT(CONCAT('%', #{pd.REGISTRANT}),'%')
</if>
<if test="pd.DUE_DATE != null and pd.DUE_DATE != ''">
and f.DUE_DATE = #{pd.DUE_DATE}
</if>
<if test="pd.VEHICLE_MODEL != null and pd.VEHICLE_MODEL != ''">
and f.VEHICLE_MODEL LIKE CONCAT(CONCAT('%', #{pd.VEHICLE_MODEL}),'%')
</if>
<if test="pd.REMINDER_STATUS != null and pd.REMINDER_STATUS != ''">
and f.REMINDER_STATUS = #{pd.REMINDER_STATUS}
</if>
<if test="pd.DUE_DATE_TYPE != null and pd.DUE_DATE_TYPE != ''">
and case when f.DUE_DATE &lt; NOW() then 0 else 1 end = #{pd.DUE_DATE_TYPE}
</if>
ORDER BY f.CREATTIME DESC
</select>
<select id="annuallyList" parameterType="page" resultType="pd">
select
*
from
<include refid="tableName"></include> f
where
f.ISDELETE = '0'
AND
f.CORPINFO_ID = #{pd.CORPINFO_ID}
</select>
<select id="listOut" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where f.ISDELETE = '0'
and f.INSPECTANNUALLY_ID in
<foreach item="item" index="index" open="(" separator="," close=")" collection="ArrayDATA_IDS">
#{item}
</foreach>
</select>
<select id="getYestoday" parameterType="pd" resultType="pd">
select
b.NAME,
case when f.VEHICLE_MODEL = '1' then '营运车辆' else '货运挂车' end as VEHICLEMODEL,
f.*,
v1.PLATE_NUMBER
from
<include refid="tableName"></include> f
LEFT JOIN sys_dictionaries b on f.ANNUAL_INSPECTION_CYCLE = b.DICTIONARIES_ID AND b.PARENT_ID = '8b7dea3977fd4360a3cc8112368b90ff'
INNER JOIN v_traffic v1 on f.VEHICLE = v1.ID
LEFT JOIN bus_traffic_operatingvehicle bto on bto.OPERATING_ID = f.VEHICLE
LEFT JOIN bus_traffic_mechanical_freighttrailer btmf on btmf.FREIGHTTRAILER_ID = f.VEHICLE
where f.ISDELETE = '0'
AND (bto.ISSCRAP = '0' OR btmf.ISSCRAP = '0')
AND f.DUE_DATE != ''
AND TO_DAYS( NOW() ) - TO_DAYS( f.DUE_DATE ) = 0
AND f.REMINDER_STATUS = '1'
</select>
</mapper>