integrated_traffic/src/main/resources/mybatis/datasource/operations/OperationsMapper.xml

261 lines
8.2 KiB
XML
Raw Blame History

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.zcloud.mapper.datasource.operations.OperationsMapper">
<!--表名 -->
<sql id="tableName">
bus_traffic_mechanical_operations
</sql>
<!-- 字段 -->
<sql id="Field">
OPERATIONS_ID,
CORPINFO_ID,
INDUSTRY_TYPE,
INDUSTRY_TYPE_TREE,
INDUSTRY_TYPE_NAMES,
OPER_CORP,
VEHICLE_MODEL,
VEHICLE,
BASICINFO_LICENSE_PLATE,
BASICINFO_VIN,
BASICINFO_VEHICLETYPE,
BASICINFO_CAR_OWNERS,
BASICINFO_CARPHONE,
BASICINFO_INITIAL_REGISTRATION_DATE,
BASICINFO_PROVINCE,
BASICINFO_CITY,
BASICINFO_COUNTY,
CAR_OWNERS,
TELEPHONE,
REGISTRANT,
PROCESSING_DATE,
CYCLE,
DUE_DATE,
REMINDER_DAYS,
REMINDER_DATE,
REMINDER_STATUS,
OPERATIONSINFO,
NOTES,
NUM,
ISDELETE,
CREATOR,
CREATORNAME,
CREATTIME,
OPERATOR,
OPERATORNAME,
OPERATTIME,
DELETEOR,
DELETEORNAME,
DELETTIME
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{OPERATIONS_ID},
#{CORPINFO_ID},
#{INDUSTRY_TYPE},
#{INDUSTRY_TYPE_TREE},
#{INDUSTRY_TYPE_NAMES},
#{OPER_CORP},
#{VEHICLE_MODEL},
#{VEHICLE},
#{BASICINFO_LICENSE_PLATE},
#{BASICINFO_VIN},
#{BASICINFO_VEHICLETYPE},
#{BASICINFO_CAR_OWNERS},
#{BASICINFO_CARPHONE},
#{BASICINFO_INITIAL_REGISTRATION_DATE},
#{BASICINFO_PROVINCE},
#{BASICINFO_CITY},
#{BASICINFO_COUNTY},
#{CAR_OWNERS},
#{TELEPHONE},
#{REGISTRANT},
#{PROCESSING_DATE},
#{CYCLE},
#{DUE_DATE},
#{REMINDER_DAYS},
#{REMINDER_DATE},
#{REMINDER_STATUS},
#{OPERATIONSINFO},
#{NOTES},
#{NUM},
#{ISDELETE},
#{CREATOR},
#{CREATORNAME},
#{CREATTIME},
#{OPERATOR},
#{OPERATORNAME},
#{OPERATTIME},
#{DELETEOR},
#{DELETEORNAME},
#{DELETTIME}
</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
OPERATIONS_ID = #{OPERATIONS_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
VEHICLE_MODEL = #{VEHICLE_MODEL},
VEHICLE = #{VEHICLE},
CAR_OWNERS = #{CAR_OWNERS},
TELEPHONE = #{TELEPHONE},
REGISTRANT = #{REGISTRANT},
PROCESSING_DATE = #{PROCESSING_DATE},
CYCLE = #{CYCLE},
DUE_DATE = #{DUE_DATE},
REMINDER_DAYS = #{REMINDER_DAYS},
REMINDER_DATE = #{REMINDER_DATE},
REMINDER_STATUS = #{REMINDER_STATUS},
OPERATIONSINFO = #{OPERATIONSINFO},
NOTES = #{NOTES},
OPERATOR = #{OPERATOR},
OPERATORNAME = #{OPERATORNAME},
OPERATTIME = #{OPERATTIME}
where
OPERATIONS_ID = #{OPERATIONS_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
OPERATIONS_ID = #{OPERATIONS_ID}
</update>
<!-- 通过ID获取数据 -->
<select id="findById" parameterType="pd" resultType="pd">
select
f.OPERATIONS_ID,
f.CORPINFO_ID,
f.VEHICLE_MODEL,
f.VEHICLE,
f.CAR_OWNERS,
f.TELEPHONE,
f.REGISTRANT,
f.PROCESSING_DATE,
f.CYCLE,
f.DUE_DATE,
f.REMINDER_DAYS,
f.REMINDER_DATE,
f.NUM,
f.REMINDER_STATUS,
(select t.FILEPATH from bus_imgfiles t where t.TYPE = 126 and t.FOREIGN_KEY = f.OPERATIONS_ID limit 1) as OPERATIONSINFO,
f.NOTES,
f.ISDELETE,
f.CREATOR,
f.CREATORNAME,
f.CREATTIME,
f.OPERATOR,
f.OPERATORNAME,
f.OPERATTIME,
f.DELETEOR,
f.DELETEORNAME,
f.DELETTIME
from
<include refid="tableName"></include>
f
where
f.OPERATIONS_ID = #{OPERATIONS_ID}
</select>
<!-- 列表
BASICINFO_LICENSE_PLATE 车牌号
CAR_OWNERS 车主业户
REGISTRANT 登记人
DUE_DATE 到期日期
VEHICLE_MODEL 营运车型
REMINDER_STATUS 提醒状态
-->
<select id="datalistPage" parameterType="page" resultType="pd">
select
f.*,
case when f.DUE_DATE &lt; NOW() then 0 else 1 end as DUE_DATE_TYPE,
v1.PLATE_NUMBER,
case
when btsm.PLATE_NUMBER is not null then '1'
when bta.RAW_PLATE_NUMBER is not null then '2'
else f.ARCHIVES_TYPE
end as NEW_ARCHIVES_TYPE,
COALESCE((SELECT sd.NAME FROM sys_dictionaries sd WHERE sd.DICTIONARIES_ID=f.CYCLE AND sd.PARENT_ID='8b7dea3977fd4360a3cc8112368b90ff'), '0') as CYCLE_NAME,
COALESCE(bta.RAW_PLATE_NUMBER, '0') as RAW_PLATE_NUMBER
from
<include refid="tableName"></include>
f
INNER JOIN v_traffic v1 on f.VEHICLE=v1.ID
LEFT JOIN BUS_TRAFFIC_SCRAP_MANAGEMENT btsm on v1.PLATE_NUMBER = btsm.PLATE_NUMBER
LEFT JOIN BUS_TRAFFIC_ASSIGNED bta on v1.PLATE_NUMBER = bta.RAW_PLATE_NUMBER
where f.ISDELETE = '0' and f.CORPINFO_ID = #{pd.CORPINFO_ID}
<if test="pd.BASICINFO_LICENSE_PLATE != null and pd.BASICINFO_LICENSE_PLATE != ''">
and f.BASICINFO_LICENSE_PLATE LIKE CONCAT(CONCAT('%', #{pd.BASICINFO_LICENSE_PLATE}),'%')
</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.PLATE_NUMBER != null and pd.PLATE_NUMBER != ''">
and v1.PLATE_NUMBER LIKE CONCAT(CONCAT('%', #{pd.PLATE_NUMBER}),'%')
</if>
<if test="pd.DUE_DATE_TYPE != null and pd.DUE_DATE_TYPE != ''">
-- 添加条件只有当当前时间NOW())处于提醒时间段内时,才会返回相应的记录。
-- 提醒时间段是由两个日期定义的:
-- 1. 提前提醒的日期即从DUE_DATE字段指定的到期日期减去REMINDER_DAYS字段指定的天数。
-- 2. 到期日期DUE_DATE字段本身。
-- DATE_SUB函数用于计算提前提醒的日期。它从到期日期中减去一定天数以得到提醒开始的日期。
-- DATE_SUB的第一个参数是到期日期f.DUE_DATE
-- 第二个参数INTERVAL f.REMINDER_DAYS DAY指定从到期日期向前推算的天数f.REMINDER_DAYS字段的值
and NOW() BETWEEN DATE_SUB(f.DUE_DATE, INTERVAL f.REMINDER_DAYS DAY) AND f.DUE_DATE
</if>
ORDER BY f.CREATTIME DESC
</select>
</mapper>