838 lines
38 KiB
XML
838 lines
38 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="cn.iocoder.yudao.module.inspection.mapper.InspectionInfoMapper">
|
||
|
||
<resultMap type="cn.iocoder.yudao.module.inspection.entity.InspectionInfo" id="InspectionInfoResult">
|
||
<result property="id" column="id" />
|
||
<result property="inspectionOrderId" column="inspection_order_id" />
|
||
<result property="workId" column="work_id" />
|
||
<result property="workerName" column="worker_name" />
|
||
<result property="workerPhone" column="worker_phone" />
|
||
<result property="isPass" column="is_pass" />
|
||
<result property="status" column="status" />
|
||
<result property="startTime" column="start_time" />
|
||
<result property="endTime" column="end_time" />
|
||
<result property="year" column="year" />
|
||
<result property="month" column="month" />
|
||
<result property="day" column="day" />
|
||
<result property="createTime" column="create_time" />
|
||
<result property="creator" column="creator" />
|
||
<result property="updateTime" column="update_time" />
|
||
<result property="updater" column="updater" />
|
||
</resultMap>
|
||
|
||
<sql id="selectInspectionInfoVo">
|
||
select id,buy_name,buy_phone,user_address, inspection_order_id, work_id, worker_name, worker_phone, is_pass, status, start_time, end_time, year, month, day, create_time, creator, update_time, updater from inspection_info
|
||
</sql>
|
||
|
||
<select id="selectInspectionInfoList" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo" resultMap="InspectionInfoResult">
|
||
<include refid="selectInspectionInfoVo"/>
|
||
<where>
|
||
<if test="vo.inspectionOrderId != null "> and inspection_order_id = #{vo.inspectionOrderId}</if>
|
||
<if test="vo.workId != null "> and work_id = #{vo.workId}</if>
|
||
<if test="vo.workerName != null and vo.workerName != ''"> and worker_name like concat('%', #{vo.workerName}, '%')</if>
|
||
<if test="vo.workerPhone != null and vo.workerPhone != ''"> and worker_phone = #{vo.workerPhone}</if>
|
||
<if test="vo.isPass != null and vo.isPass != ''"> and is_pass = #{vo.isPass}</if>
|
||
<if test="vo.status != null and vo.status != ''"> and status = #{vo.status}</if>
|
||
<if test="vo.startTime != null "> and start_time = #{vo.startTime}</if>
|
||
<if test="vo.endTime != null "> and end_time = #{vo.endTime}</if>
|
||
<if test="vo.year != null and vo.year != ''"> and year = #{vo.year}</if>
|
||
<if test="vo.month != null and vo.month != ''"> and month = #{vo.month}</if>
|
||
<if test="vo.day != null and vo.day != ''"> and day = #{vo.day}</if>
|
||
</where>
|
||
</select>
|
||
|
||
<select id="selectInspectionInfoById" parameterType="Long" resultMap="InspectionInfoResult">
|
||
select info.*,o.sku_name,o.sku_id,o.goods_id
|
||
from inspection_info info
|
||
left join order_info o on info.inspection_order_id = o.id
|
||
where info.id = #{id}
|
||
</select>
|
||
|
||
<insert id="insertInspectionInfo" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
insert into inspection_info
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="id != null">id,</if>
|
||
<if test="inspectionOrderId != null">inspection_order_id,</if>
|
||
<if test="workId != null">work_id,</if>
|
||
<if test="workerName != null">worker_name,</if>
|
||
<if test="workerPhone != null">worker_phone,</if>
|
||
<if test="isPass != null">is_pass,</if>
|
||
<if test="status != null">status,</if>
|
||
<if test="startTime != null">start_time,</if>
|
||
<if test="endTime != null">end_time,</if>
|
||
<if test="year != null">year,</if>
|
||
<if test="month != null">month,</if>
|
||
<if test="day != null">day,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="creator != null">creator,</if>
|
||
<if test="updateTime != null">update_time,</if>
|
||
<if test="updater != null">updater,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="id != null">#{id},</if>
|
||
<if test="inspectionOrderId != null">#{inspectionOrderId},</if>
|
||
<if test="workId != null">#{workId},</if>
|
||
<if test="workerName != null">#{workerName},</if>
|
||
<if test="workerPhone != null">#{workerPhone},</if>
|
||
<if test="isPass != null">#{isPass},</if>
|
||
<if test="status != null">#{status},</if>
|
||
<if test="startTime != null">#{startTime},</if>
|
||
<if test="endTime != null">#{endTime},</if>
|
||
<if test="year != null">#{year},</if>
|
||
<if test="month != null">#{month},</if>
|
||
<if test="day != null">#{day},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="creator != null">#{creator},</if>
|
||
<if test="updateTime != null">#{updateTime},</if>
|
||
<if test="updater != null">#{updater},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateInspectionInfo" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
update inspection_info
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="inspectionOrderId != null">inspection_order_id = #{inspectionOrderId},</if>
|
||
<if test="workId != null">work_id = #{workId},</if>
|
||
<if test="workerName != null">worker_name = #{workerName},</if>
|
||
<if test="workerPhone != null">worker_phone = #{workerPhone},</if>
|
||
<if test="isPass != null">is_pass = #{isPass},</if>
|
||
<if test="status != null">status = #{status},</if>
|
||
<if test="startTime != null">start_time = #{startTime},</if>
|
||
<if test="endTime != null">end_time = #{endTime},</if>
|
||
<if test="year != null">year = #{year},</if>
|
||
<if test="month != null">month = #{month},</if>
|
||
<if test="day != null">day = #{day},</if>
|
||
<if test="createTime != null">create_time = #{createTime},</if>
|
||
<if test="creator != null">creator = #{creator},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
<if test="updater != null">updater = #{updater},</if>
|
||
</trim>
|
||
where id = #{id}
|
||
</update>
|
||
|
||
<delete id="deleteInspectionInfoById" parameterType="Long">
|
||
UPDATE inspection_info SET deleted = 1 WHERE id = #{id}
|
||
</delete>
|
||
|
||
<delete id="deleteInspectionInfoByIds" parameterType="String">
|
||
delete from inspection_info where id in
|
||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</delete>
|
||
<select id="workOrder" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
select DISTINCT ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
|
||
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,ins.create_time
|
||
from inspection_info ins
|
||
left join order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1
|
||
<if test="carNum!=null and carNum!=''">
|
||
and ins.car_num like concat('%',#{carNum},'%')
|
||
</if>
|
||
<if test="goodsTitle!=null and goodsTitle!=''">
|
||
and oi.goods_title like concat('%',#{goodsTitle},'%')
|
||
</if>
|
||
<if test="roleId!=null and roleId!=''">
|
||
and sur.role_id = #{roleId}
|
||
</if>
|
||
|
||
<if test="customerSource!=null and customerSource!=''">
|
||
and ins.customer_source =#{customerSource}
|
||
</if>
|
||
<if test="payType!=null and payType!=''">
|
||
and oi.pay_type = #{payType}
|
||
</if>
|
||
<if test="startTime!=null and startTime!=''">
|
||
and ins.start_time between #{startTime} and #{endTime}
|
||
</if>
|
||
order by ins.start_time desc
|
||
</select>
|
||
|
||
<select id="delworkOrder" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
select ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
|
||
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,ins.create_time
|
||
from del_inspection_info ins
|
||
left join del_order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1
|
||
<if test="carNum!=null and carNum!=''">
|
||
and ins.car_num like concat('%',#{carNum},'%')
|
||
</if>
|
||
<if test="goodsTitle!=null and goodsTitle!=''">
|
||
and oi.goods_title like concat('%',#{goodsTitle},'%')
|
||
</if>
|
||
<if test="roleId!=null and roleId!=''">
|
||
and sur.role_id = #{roleId}
|
||
</if>
|
||
|
||
<if test="customerSource!=null and customerSource!=''">
|
||
and ins.customer_source =#{customerSource}
|
||
</if>
|
||
<if test="payType!=null and payType!=''">
|
||
and oi.pay_type = #{payType}
|
||
</if>
|
||
<if test="startTime!=null and startTime!=''">
|
||
and ins.start_time between #{startTime} and #{endTime}
|
||
</if>
|
||
order by ins.start_time desc
|
||
</select>
|
||
|
||
<select id="workOrderData" resultType="java.util.Map">
|
||
select ifnull(sum(oi.pay_money),0) as payMoneySum,ifnull(sum(oi.goods_price),0) goodsPriceSum
|
||
from inspection_info ins
|
||
left join order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1
|
||
<if test="carNum!=null and carNum!=''">
|
||
and ins.car_num like concat('%',#{carNum},'%')
|
||
</if>
|
||
<if test="goodsTitle!=null and goodsTitle!=''">
|
||
and oi.goods_title like concat('%',#{goodsTitle},'%')
|
||
</if>
|
||
<if test="roleId!=null and roleId!=''">
|
||
and sur.role_id = #{roleId}
|
||
</if>
|
||
|
||
<if test="customerSource!=null and customerSource!=''">
|
||
and ins.customer_source =#{customerSource}
|
||
</if>
|
||
<if test="payType!=null and payType!=''">
|
||
and oi.pay_type = #{payType}
|
||
</if>
|
||
<if test="startTime!=null and startTime!=''">
|
||
and ins.start_time between #{startTime} and #{endTime}
|
||
</if>
|
||
</select>
|
||
<select id="pageWorkOrder" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
select distinct ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
|
||
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,oi.cashier_confirm,oi.cashier_confirm_remark
|
||
from inspection_info ins
|
||
left join order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1
|
||
<if test="carNum!=null and carNum!=''">
|
||
and ins.car_num like concat('%',#{carNum},'%')
|
||
</if>
|
||
<if test="goodsTitle!=null and goodsTitle!=''">
|
||
and oi.goods_title like concat('%',#{goodsTitle},'%')
|
||
</if>
|
||
<if test="roleId!=null and roleId!=''">
|
||
and sur.role_id = #{roleId}
|
||
</if>
|
||
|
||
<if test="customerSource!=null and customerSource!=''">
|
||
and ins.customer_source =#{customerSource}
|
||
</if>
|
||
<if test="payType!=null and payType!=''">
|
||
and oi.pay_type = #{payType}
|
||
</if>
|
||
<if test="startTime!=null and startTime!=''">
|
||
and ins.start_time between #{startTime} and #{endTime}
|
||
</if>
|
||
order by ins.start_time desc
|
||
</select>
|
||
<select id="pageDelWorkOrder" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
select ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as realPayMoney
|
||
,oi.pay_type,oi.order_status as orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,ins.create_time
|
||
from del_inspection_info ins
|
||
left join del_order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1
|
||
<if test="carNum!=null and carNum!=''">
|
||
and ins.car_num like concat('%',#{carNum},'%')
|
||
</if>
|
||
<if test="goodsTitle!=null and goodsTitle!=''">
|
||
and oi.goods_title like concat('%',#{goodsTitle},'%')
|
||
</if>
|
||
<if test="roleId!=null and roleId!=''">
|
||
and sur.role_id = #{roleId}
|
||
</if>
|
||
|
||
<if test="customerSource!=null and customerSource!=''">
|
||
and ins.customer_source =#{customerSource}
|
||
</if>
|
||
<if test="payType!=null and payType!=''">
|
||
and oi.pay_type = #{payType}
|
||
</if>
|
||
<if test="startTime!=null and startTime!=''">
|
||
and ins.start_time between #{startTime} and #{endTime}
|
||
</if>
|
||
order by ins.start_time desc
|
||
</select>
|
||
<select id="selectByUser" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
<if test="inspectionInfo.status != 6 and inspectionInfo.status != 8">
|
||
SELECT *
|
||
FROM (
|
||
SELECT
|
||
ii.*,
|
||
iwn.id AS workNodeId,
|
||
iwn.status AS workNodeStatus,
|
||
oi.order_no AS orderNo,
|
||
oi.phonenumber AS buyPhone,
|
||
oi.goods_title as goodsTitle,
|
||
oi.sku_name as skuName,
|
||
ip.project_name AS projectName,
|
||
su.nickname AS leadManName,
|
||
ROW_NUMBER() OVER (PARTITION BY ii.id ORDER BY iwn.update_time DESC) as rn -- 根据需要调整排序逻辑
|
||
FROM
|
||
inspection_info ii
|
||
LEFT JOIN
|
||
inspection_work_node iwn ON ii.id = iwn.inspection_info_id
|
||
LEFT JOIN
|
||
order_info oi ON ii.inspection_order_id = oi.id
|
||
LEFT JOIN
|
||
inspection_project ip ON iwn.project_id = ip.id
|
||
LEFT JOIN
|
||
system_users su ON ii.lead_man_id = su.id
|
||
<where>
|
||
ii.deleted = 0
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
<!-- 待支付 -->
|
||
<if test="inspectionInfo.status == '0'.toString()">
|
||
AND (oi.pay_time is null)
|
||
ORDER BY iwn.update_time DESC
|
||
</if>
|
||
<!-- 待接受(待检测) -->
|
||
<if test="inspectionInfo.status == 1">
|
||
AND <!-- 工单负责人或角色ID匹配 -->
|
||
(ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
AND ii.status = '0'
|
||
AND iwn.status = '0'
|
||
-- AND ii.now_order_num = iwn.order_num
|
||
ORDER BY ii.create_time DESC
|
||
</if>
|
||
<!-- 进行中(检测中) -->
|
||
<if test="inspectionInfo.status == 2">
|
||
AND (ii.status = '0' OR ii.status = '2')
|
||
AND iwn.status = '1'
|
||
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
|
||
ORDER BY iwn.update_time DESC
|
||
</if>
|
||
<!-- 待重检 -->
|
||
<if test="inspectionInfo.status == 3">
|
||
AND <!-- 工单负责人或角色ID匹配 -->
|
||
(ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
AND ii.status = '2'
|
||
-- AND iwn.status = '1'
|
||
-- AND ii.now_order_num = iwn.order_num
|
||
ORDER BY ii.update_time DESC
|
||
</if>
|
||
<!-- 待复检 -->
|
||
<if test="inspectionInfo.status == 4">
|
||
AND <!-- 工单负责人或角色ID匹配 -->
|
||
(ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
-- AND ii.status = '2'
|
||
AND iwn.status = '3'
|
||
AND ii.status != '1'
|
||
-- AND ii.now_order_num = iwn.order_num
|
||
ORDER BY ii.update_time DESC
|
||
</if>
|
||
<!-- 已完成 -->
|
||
<if test="inspectionInfo.status == 5">
|
||
AND iwn.status = '2'
|
||
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
|
||
ORDER BY iwn.update_time DESC
|
||
</if>
|
||
<!-- 待接车 -->
|
||
<if test="inspectionInfo.status == 6">
|
||
AND ii.is_meet_car = '0'
|
||
AND ii.meet_man_id = #{inspectionInfo.dealUserId}
|
||
ORDER BY iwn.update_time DESC
|
||
</if>
|
||
<!-- 待审核不合格项目 -->
|
||
<if test="inspectionInfo.status == 7">
|
||
AND iwn.type = '0'
|
||
AND ii.status != '1'
|
||
ORDER BY iwn.update_time DESC
|
||
</if>
|
||
<!-- 新增:lead_man_id 为空 -->
|
||
<if test="inspectionInfo.status == 9">
|
||
AND ii.lead_man_id IS NULL
|
||
AND ii.status = '0'
|
||
ORDER BY ii.update_time DESC
|
||
</if>
|
||
<!-- 还车 -->
|
||
<if test="inspectionInfo.status == 10">
|
||
AND ii.is_return_car != 1
|
||
AND ii.status = '1'
|
||
ORDER BY ii.update_time DESC
|
||
</if>
|
||
</where>
|
||
) AS subquery
|
||
WHERE rn = 1;
|
||
</if>
|
||
<!-- 待接车 -->
|
||
<if test="inspectionInfo.status == 6">
|
||
SELECT
|
||
ii.id AS id,
|
||
ii.buy_name,
|
||
ii.user_address,
|
||
ii.car_num,
|
||
ii.car_nature,
|
||
ii.car_model,
|
||
ii.car_id_no,
|
||
ii.car_register_date,
|
||
ii.buy_phone,
|
||
ii.meet_man_id AS meet_id,
|
||
ii.tenant_id,
|
||
ii.create_time,
|
||
null AS meetAddress,
|
||
null AS latitude,
|
||
null AS longitude,
|
||
null AS appointmentDay,
|
||
null AS appointmentTime,
|
||
null AS is_pick_car,
|
||
0 AS source_type
|
||
FROM inspection_info ii
|
||
WHERE ii.deleted = 0 AND ii.meet_man_id = #{inspectionInfo.dealUserId} AND ii.is_meet_car = '0' AND ii.status != '1'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
|
||
UNION ALL
|
||
|
||
SELECT
|
||
imco.id AS id,
|
||
imco.buy_name,
|
||
imco.user_address,
|
||
imco.car_num,
|
||
imco.car_nature,
|
||
imco.car_model,
|
||
imco.car_id_no,
|
||
imco.car_register_date,
|
||
imco.buy_phone,
|
||
imco.meet_man_id,
|
||
imco.tenant_id,
|
||
imco.create_time,
|
||
imco.meet_address AS meetAddress,
|
||
imco.latitude,
|
||
imco.longitude,
|
||
imco.appointment_day,
|
||
imco.appointment_time,
|
||
imco.is_pick_car,
|
||
1 AS source_type
|
||
FROM inspection_meet_car_order imco
|
||
WHERE imco.deleted = 0 AND imco.meet_man_id = #{inspectionInfo.dealUserId} AND imco.is_meet = '0'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND imco.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
|
||
</if>
|
||
<!-- 接车订单转工单 -->
|
||
<if test="inspectionInfo.status == 8">
|
||
SELECT imco.*,iisi.content
|
||
FROM inspection_meet_car_order imco
|
||
LEFT JOIN inspection_step_info iisi ON imco.id = iisi.inspection_info_id
|
||
WHERE imco.deleted = 0 AND imco.inspection_info_id IS NULL AND imco.is_meet = '1'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND imco.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
</if>
|
||
<!-- 之前的查询,修改为了一个工单只出现一条,不分项目 -->
|
||
<!-- SELECT-->
|
||
<!-- ii.*,-->
|
||
<!-- iwn.id AS workNodeId,-->
|
||
<!-- iwn.status AS workNodeStatus,-->
|
||
<!-- oi.order_no AS orderNo,-->
|
||
<!-- oi.phonenumber AS buyPhone,-->
|
||
<!-- ip.project_name AS projectName,-->
|
||
<!-- su.nickname AS leadManName-->
|
||
<!-- FROM-->
|
||
<!-- inspection_info ii-->
|
||
<!-- LEFT JOIN-->
|
||
<!-- inspection_work_node iwn ON ii.id = iwn.inspection_info_id-->
|
||
<!-- LEFT JOIN-->
|
||
<!-- order_info oi ON ii.inspection_order_id = oi.id-->
|
||
<!-- LEFT JOIN-->
|
||
<!-- inspection_project ip ON iwn.project_id = ip.id-->
|
||
<!-- LEFT JOIN-->
|
||
<!-- system_users su ON ii.lead_man_id = su.id-->
|
||
<!-- <where>-->
|
||
<!-- <!– 车牌号模糊查询 –>-->
|
||
<!-- <if test="inspectionInfo.carNum != null">-->
|
||
<!-- AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')-->
|
||
<!-- </if>-->
|
||
<!-- <!– 待接受 –>-->
|
||
<!-- <if test="inspectionInfo.status == 1">-->
|
||
<!-- AND <!– 工单负责人或角色ID匹配 –>-->
|
||
<!-- (ii.lead_man_id = #{inspectionInfo.leadManId}-->
|
||
<!-- OR iwn.role_id IN-->
|
||
<!-- <foreach collection="roleIds" item="roleId" open="(" separator="," close=")">-->
|
||
<!-- #{roleId}-->
|
||
<!-- </foreach>)-->
|
||
<!-- AND ii.status = '0'-->
|
||
<!-- AND iwn.status = '0'-->
|
||
<!-- -- AND ii.now_order_num = iwn.order_num-->
|
||
<!-- ORDER BY ii.create_time DESC-->
|
||
<!-- </if>-->
|
||
<!-- <!– 进行中 –>-->
|
||
<!-- <if test="inspectionInfo.status == 2">-->
|
||
<!-- AND ii.status = '0'-->
|
||
<!-- AND iwn.status = '1'-->
|
||
<!-- AND iwn.deal_user_id = #{inspectionInfo.dealUserId}-->
|
||
<!-- ORDER BY iwn.update_time DESC-->
|
||
<!-- </if>-->
|
||
<!-- <!– 已完成 –>-->
|
||
<!-- <if test="inspectionInfo.status == 3">-->
|
||
<!-- AND iwn.status = '2'-->
|
||
<!-- AND iwn.deal_user_id = #{inspectionInfo.dealUserId}-->
|
||
<!-- ORDER BY iwn.update_time DESC-->
|
||
<!-- </if>-->
|
||
<!-- </where>-->
|
||
</select>
|
||
<select id="countByUser" resultType="java.lang.Long">
|
||
<if test="inspectionInfo.status != 6 and inspectionInfo.status != 8">
|
||
SELECT COUNT(DISTINCT ii.id)
|
||
FROM inspection_info ii
|
||
LEFT JOIN inspection_work_node iwn ON ii.id = iwn.inspection_info_id
|
||
LEFT JOIN order_info oi ON ii.inspection_order_id = oi.id
|
||
LEFT JOIN inspection_project ip ON iwn.project_id = ip.id
|
||
LEFT JOIN system_users su ON ii.lead_man_id = su.id
|
||
<where>
|
||
ii.deleted = 0
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
<!-- 待支付 -->
|
||
<if test="inspectionInfo.status == '0'.toString()">
|
||
AND (oi.pay_time is null)
|
||
</if>
|
||
<!-- 待接受(待检测) -->
|
||
<if test="inspectionInfo.status == 1">
|
||
AND (ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
AND ii.status = '0'
|
||
AND iwn.status = '0'
|
||
</if>
|
||
<!-- 进行中(检测中) -->
|
||
<if test="inspectionInfo.status == 2">
|
||
AND (ii.status = '0' OR ii.status = '2')
|
||
AND iwn.status = '1'
|
||
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
|
||
</if>
|
||
<!-- 待重检 -->
|
||
<if test="inspectionInfo.status == 3">
|
||
AND (ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
AND ii.status = '2'
|
||
</if>
|
||
<!-- 待复检 -->
|
||
<if test="inspectionInfo.status == 4">
|
||
AND (ii.lead_man_id = #{inspectionInfo.leadManId}
|
||
OR iwn.role_id IN
|
||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||
#{roleId}
|
||
</foreach>)
|
||
AND iwn.status = '3'
|
||
AND ii.status != '1'
|
||
</if>
|
||
<!-- 已完成 -->
|
||
<if test="inspectionInfo.status == 5">
|
||
AND iwn.status = '2'
|
||
AND iwn.deal_user_id = #{inspectionInfo.dealUserId}
|
||
</if>
|
||
<!-- 待审核不合格项目 -->
|
||
<if test="inspectionInfo.status == 7">
|
||
AND iwn.type = '0'
|
||
AND ii.status != '1'
|
||
</if>
|
||
<!-- 新增:lead_man_id 为空 -->
|
||
<if test="inspectionInfo.status == 9">
|
||
AND ii.lead_man_id IS NULL
|
||
AND ii.status = '0'
|
||
</if>
|
||
<!-- 还车 -->
|
||
<if test="inspectionInfo.status == 10">
|
||
AND ii.is_return_car != 1
|
||
AND ii.status = '1'
|
||
ORDER BY ii.update_time DESC
|
||
</if>
|
||
</where>
|
||
</if>
|
||
<if test="inspectionInfo.status == 6">
|
||
SELECT COUNT(*) FROM (
|
||
SELECT ii.id
|
||
FROM inspection_info ii
|
||
WHERE ii.deleted = 0
|
||
AND ii.meet_man_id = #{inspectionInfo.dealUserId}
|
||
AND ii.is_meet_car = '0'
|
||
AND ii.status != '1'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND ii.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
|
||
UNION ALL
|
||
|
||
SELECT imco.id
|
||
FROM inspection_meet_car_order imco
|
||
WHERE imco.deleted = 0
|
||
AND imco.meet_man_id = #{inspectionInfo.dealUserId}
|
||
AND imco.is_meet = '0'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND imco.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
) AS combined_results
|
||
</if>
|
||
<!-- 接车订单转工单 -->
|
||
<if test="inspectionInfo.status == 8">
|
||
SELECT COUNT(*)
|
||
FROM inspection_meet_car_order imco
|
||
WHERE imco.deleted = 0 AND imco.inspection_info_id IS NULL AND imco.is_meet = '1'
|
||
<!-- 车牌号模糊查询 -->
|
||
<if test="inspectionInfo.carNum != null">
|
||
AND imco.car_num LIKE CONCAT('%', #{inspectionInfo.carNum}, '%')
|
||
</if>
|
||
</if>
|
||
</select>
|
||
<select id="geStelectInspectionByBusiness" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
SELECT
|
||
imco.meet_man_id,
|
||
imco.buy_name,
|
||
imco.buy_phone,
|
||
imco.car_num,
|
||
imco.other_phone,
|
||
imco.inspection_info_id AS inspectionInfoId,
|
||
|
||
-- 以下是 status != 1 时才会返回的字段
|
||
<if test="info.status != 1">
|
||
ii.id AS id,
|
||
ii.status AS status,
|
||
ii.worker_name AS workerName,
|
||
ii.worker_phone AS workerPhone,
|
||
ii.car_model AS carModel,
|
||
ii.car_nature AS carNature,
|
||
ii.car_status AS carStatus,
|
||
ii.car_id_no AS carIdNo,
|
||
ii.buy_name AS buyName,
|
||
ii.buy_phone AS buyPhone,
|
||
ii.unit_name AS unitName,
|
||
ii.remark AS remark,
|
||
ii.start_time AS startTime,
|
||
ii.end_time AS endTime,
|
||
ii.is_pass AS isPass,
|
||
ii.is_retrial AS isRetrial,
|
||
ii.recheck_count AS recheckCount,
|
||
ii.reinspect_count AS reinspectCount,
|
||
ii.other_phone AS otherPhone,
|
||
ii.is_pay_online AS isPayOnline,
|
||
ii.is_pick_car AS isPickCar,
|
||
oi.sku_name AS skuName,
|
||
oi.goods_title AS goodsTitle
|
||
</if>
|
||
|
||
-- status == 1,说明只有 meet_car 数据,需要返回 id 字段(占位)
|
||
<if test="info.status == 1">
|
||
imco.id AS id
|
||
</if>
|
||
|
||
FROM inspection_meet_car_order imco
|
||
LEFT JOIN inspection_business_channel ibc ON imco.customer_source_id = ibc.id
|
||
LEFT JOIN system_users su
|
||
ON su.username COLLATE utf8mb4_general_ci = imco.other_phone COLLATE utf8mb4_general_ci
|
||
|
||
<if test="info.status != 1">
|
||
LEFT JOIN inspection_info ii ON imco.inspection_info_id = ii.id AND ii.deleted = 0
|
||
LEFT JOIN order_info oi ON ii.inspection_order_id = oi.id AND oi.deleted = 0
|
||
</if>
|
||
|
||
WHERE imco.deleted = 0 AND ibc.deleted = 0
|
||
|
||
<if test="info.userId != null and info.userId != ''">
|
||
AND (FIND_IN_SET(#{info.userId}, ibc.user_ids) OR su.id = #{info.userId})
|
||
</if>
|
||
|
||
<if test="info.carNum != null and info.carNum != ''">
|
||
AND imco.car_num LIKE CONCAT('%', #{info.carNum}, '%')
|
||
</if>
|
||
|
||
<if test="info.status != null and info.status != 1">
|
||
<if test="info.status == 2">
|
||
AND ii.status = '0'
|
||
</if>
|
||
<if test="info.status == 3">
|
||
AND ii.status = '1'
|
||
</if>
|
||
</if>
|
||
<if test="info.datetimeRange != null and info.datetimeRange.size() > 0">
|
||
<if test="info.datetimeRange.size() == 2">
|
||
AND imco.create_time BETWEEN #{info.datetimeRange[0]} AND #{info.datetimeRange[1]}
|
||
</if>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="selectMeetCarList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
SELECT ii.*, imco.meet_type
|
||
FROM inspection_info ii
|
||
LEFT JOIN inspection_meet_car_order imco ON ii.id = imco.inspection_info_id
|
||
<where>
|
||
ii.deleted = 0 AND imco.deleted = 0 AND imco.is_meet = '1'
|
||
<if test="datetimeRange != null">
|
||
AND imco.create_time BETWEEN #{datetimeRange[0]} AND #{datetimeRange[1]}
|
||
</if>
|
||
</where>
|
||
</select>
|
||
<select id="pageWorkOrderNew" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
select distinct ins.*,oi.goods_title,su.nickname as buyName,su.mobile as buyPhone,oi.sku_name,oi.pay_money as
|
||
realPayMoney
|
||
,oi.pay_type,oi.order_status as
|
||
orderStatus,oi.goods_id,oi.sku_id,oi.pay_time,oi.goods_price,oi.cashier_confirm,oi.cashier_confirm_remark,oi.cashier_confirm_time
|
||
,oi.accounting_confirm,oi.accounting_confirm_remark,
|
||
car.next_inspection_date,car.insurance_company_name,car.insurance_expiry_date,car.vehicle_insurance_expiry_date
|
||
from inspection_info ins
|
||
left join order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
LEFT JOIN shop_user_car car on car.car_no = ins.car_num
|
||
where 1=1 AND ins.deleted = 0
|
||
<if test="query.carModelOrCarYear!=null and query.carModelOrCarYear!=''">
|
||
and (ins.car_num like concat('%',#{query.carModelOrCarYear},'%')
|
||
OR ins.certificate_num like concat('%',#{query.carModelOrCarYear},'%'))
|
||
</if>
|
||
<if test="query.skuName!=null and query.skuName!=''">
|
||
and oi.sku_name like concat('%',#{query.skuName},'%')
|
||
</if>
|
||
<if test="query.customerSource!=null and query.customerSource!=''">
|
||
AND ins.customer_source = #{query.customerSource}
|
||
</if>
|
||
<if test="query.businessChannel!=null and query.businessChannel!=''">
|
||
AND ins.business_channel = #{query.businessChannel}
|
||
</if>
|
||
<if test="query.carYear!=null and query.carYear!=''">
|
||
AND (TIMESTAMPDIFF(YEAR, ins.car_register_date, CURDATE()) >= #{query.carYear}
|
||
AND TIMESTAMPDIFF(YEAR, ins.car_register_date, CURDATE()) < #{query.carYear} + 1)
|
||
</if>
|
||
<if test="query.payType!=null and query.payType!=''">
|
||
and oi.pay_type = #{query.payType}
|
||
</if>
|
||
<if test="query.startTime!=null and query.startTime!=''">
|
||
and ins.start_time between #{query.startTime} and #{query.endTime}
|
||
</if>
|
||
<if test="query.datetimeRange != null">
|
||
<if test="query.dateType != null and query.dateType.equals('jcTime')">
|
||
and ins.start_time between #{query.datetimeRange[0]} and #{query.datetimeRange[1]}
|
||
</if>
|
||
<if test="query.dateType != null and query.dateType.equals('bxTime')">
|
||
and car.insurance_expiry_date between #{query.datetimeRange[0]} and #{query.datetimeRange[1]}
|
||
</if>
|
||
<if test="query.dateType != null and query.dateType.equals('bxVehicleTime')">
|
||
and car.vehicle_insurance_expiry_date between #{query.datetimeRange[0]} and #{query.datetimeRange[1]}
|
||
</if>
|
||
<if test="query.dateType != null and query.dateType.equals('nextInspectionTime')">
|
||
and car.next_inspection_date between #{query.datetimeRange[0]} and #{query.datetimeRange[1]}
|
||
</if>
|
||
|
||
</if>
|
||
<if test="query.payStatus == 0">
|
||
and (oi.pay_money is null OR oi.pay_type = 'sz')
|
||
</if>
|
||
<if test="query.payStatus == 1">
|
||
and oi.pay_time is not null AND oi.pay_type != 'sz'
|
||
</if>
|
||
<if test="query.payStatus == 2">
|
||
and oi.cashier_confirm = 1
|
||
and (oi.accounting_confirm is null or oi.accounting_confirm != 1)
|
||
</if>
|
||
order by ins.start_time desc
|
||
</select>
|
||
<select id="workOrderDataNew" resultType="java.util.Map">
|
||
select ifnull(sum(case when oi.pay_type != 'sz' then oi.pay_money else 0 end), 0) as payMoneySum
|
||
,IFNULL(SUM(CASE WHEN NOT (ins.status = '1' AND ins.is_pass = '0') THEN oi.goods_price ELSE 0 END), 0) goodsPriceSum
|
||
from inspection_info ins
|
||
left join order_info oi on oi.id = ins.inspection_order_id
|
||
left join system_users su on su.id = ins.user_id
|
||
left join system_user_role sur on sur.user_id = su.id
|
||
where 1=1 AND ins.deleted = 0
|
||
<if test="query.carModelOrCarYear!=null and query.carModelOrCarYear!=''">
|
||
and (ins.car_num like concat('%',#{query.carModelOrCarYear},'%')
|
||
OR ins.certificate_num like concat('%',#{query.carModelOrCarYear},'%'))
|
||
</if>
|
||
<if test="query.skuName!=null and query.skuName!=''">
|
||
and oi.sku_name like concat('%',#{query.skuName},'%')
|
||
</if>
|
||
<if test="query.customerSource!=null and query.customerSource!=''">
|
||
AND ins.customer_source = #{query.customerSource}
|
||
</if>
|
||
<if test="query.businessChannel!=null and query.businessChannel!=''">
|
||
AND ins.business_channel = #{query.businessChannel}
|
||
</if>
|
||
<if test="query.carYear!=null and query.carYear!=''">
|
||
AND (TIMESTAMPDIFF(YEAR, ins.car_register_date, CURDATE()) >= #{query.carYear}
|
||
AND TIMESTAMPDIFF(YEAR, ins.car_register_date, CURDATE()) < #{query.carYear} + 1)
|
||
</if>
|
||
<if test="query.payType!=null and query.payType!=''">
|
||
and oi.pay_type = #{query.payType}
|
||
</if>
|
||
<if test="query.payStatus == 0">
|
||
and (oi.pay_time is null OR oi.pay_type = 'sz')
|
||
</if>
|
||
<if test="query.payStatus == 1">
|
||
and oi.pay_time is not null AND oi.pay_type != 'sz'
|
||
</if>
|
||
<if test="query.startTime!=null and query.startTime!=''">
|
||
and ins.start_time between #{query.startTime} and #{query.endTime}
|
||
</if>
|
||
</select>
|
||
<select id="selectLatestByCarNums" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
|
||
SELECT ii.*,car.*
|
||
FROM inspection_info ii
|
||
JOIN (
|
||
SELECT car_num, MAX(start_time) AS max_start_time
|
||
FROM inspection_info
|
||
WHERE car_num IN
|
||
<foreach collection="carNos" item="carNo" open="(" separator="," close=")">
|
||
#{carNo}
|
||
</foreach>
|
||
GROUP BY car_num
|
||
) latest
|
||
ON ii.car_num = latest.car_num AND ii.start_time = latest.max_start_time
|
||
LEFT JOIN shop_user_car car on car.car_no = ii.car_num
|
||
</select>
|
||
<select id="selectBuyUserIdsByInfoIds" resultType="java.util.Map">
|
||
SELECT
|
||
info.id AS "key",
|
||
system_users.id AS "value"
|
||
FROM inspection_info info
|
||
INNER JOIN system_users ON info.other_phone = system_users.username
|
||
WHERE info.id IN
|
||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</select>
|
||
</mapper>
|