lanan-system/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml

147 lines
6.9 KiB
XML
Raw Normal View History

2024-11-04 15:07:18 +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.inspection.mapper.InspectionWorkNodeMapper">
2024-11-14 17:50:14 +08:00
<update id="cancelAnOrder">
UPDATE inspection_work_node
SET status = '0', deal_user_id = null, deal_user_name = null, deal_images = null, remark = null
WHERE id = #{id} AND inspection_info_id = #{inspectionInfoId}
</update>
2024-11-15 17:46:37 +08:00
<update id="recheck">
UPDATE inspection_work_node
2024-12-11 15:18:50 +08:00
SET status = #{status}, deal_user_id = null, deal_user_name = null, deal_images = null, remark = null,type = null
2024-11-15 17:46:37 +08:00
WHERE id in (
<foreach collection="list" item="item" separator=",">
#{item.id}
</foreach>
)
</update>
2024-11-04 15:07:18 +08:00
<select id="getWeorkNodesById" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode"
parameterType="java.lang.Integer">
SELECT wn.*,ip.project_name AS projectName
FROM inspection_work_node wn
LEFT JOIN inspection_project ip ON ip.id = wn.project_id
WHERE wn.inspection_info_id = #{inspectionId}
2024-11-05 18:04:02 +08:00
ORDER BY wn.order_num ASC
2024-11-04 15:07:18 +08:00
</select>
2024-11-08 13:28:58 +08:00
<select id="getRoyaltyList" resultType="java.util.Map">
SELECT
node.id AS node_id,
node.project_id,
proj.project_name AS projectName, -- Assuming there's a project name in the inspection project table
node.deal_user_name AS handlerName,
IFNULL(royalty.royalty_amount, 0) / 100 AS royaltyAmount,
2024-11-08 17:35:17 +08:00
node.update_time AS node_create_time,
node.update_time AS royalty_create_time
2024-11-08 13:28:58 +08:00
FROM
inspection_work_node AS node
LEFT JOIN
system_users AS users
ON node.deal_user_id = users.id
LEFT JOIN
inspection_project AS proj -- Assuming this is the table for project details
ON node.project_id = proj.id
LEFT JOIN
inspection_info AS info
ON node.inspection_info_id = info.id
2024-11-08 17:35:17 +08:00
LEFT JOIN
order_info orders
ON info.inspection_order_id = orders.id
LEFT JOIN
inspection_project_royalty AS royalty
ON node.project_id = royalty.project_id and orders.goods_id = royalty.goods_id
2024-11-08 13:28:58 +08:00
<where>
node.status = '2' AND info.status = '1'
<if test="inspectionWorkNode.createTime != null">
AND node.create_time = #{inspectionWorkNode.createTime}
</if>
<if test="inspectionWorkNode.projectId != null">
AND node.project_id = #{inspectionWorkNode.projectId}
</if>
<if test="inspectionWorkNode.dealUserId != null">
AND node.deal_user_id = #{inspectionWorkNode.dealUserId}
</if>
<if test="inspectionWorkNode.dealUserName != null">
AND node.deal_user_name LIKE CONCAT('%', #{inspectionWorkNode.dealUserName} , '%')
</if>
<if test="inspectionWorkNode.rescueStartMonth != null">
2024-11-25 16:46:51 +08:00
AND DATE_FORMAT(node.create_time, '%Y-%m') = #{inspectionWorkNode.rescueStartMonth}
2024-11-08 13:28:58 +08:00
</if>
<if test="inspectionWorkNode.rescueStart != null and inspectionWorkNode.rescueEnd != null">
2024-11-25 16:46:51 +08:00
AND node.create_time BETWEEN #{inspectionWorkNode.rescueStart} AND #{inspectionWorkNode.rescueEnd}
2024-11-08 13:28:58 +08:00
</if>
</where>
ORDER BY
2024-11-25 16:46:51 +08:00
node.create_time DESC;
2024-11-08 13:28:58 +08:00
</select>
<select id="getRoyaltySum" resultType="java.util.Map">
SELECT
IFNULL(SUM(IFNULL(royalty.royalty_amount, 0) / 100 ),0)AS royaltyAmountSum
FROM
inspection_work_node AS node
LEFT JOIN
system_users AS users
ON node.deal_user_id = users.id
LEFT JOIN
inspection_project AS proj -- Assuming this is the table for project details
ON node.project_id = proj.id
LEFT JOIN
inspection_info AS info
ON node.inspection_info_id = info.id
2024-11-08 17:35:17 +08:00
LEFT JOIN
order_info orders
ON info.inspection_order_id = orders.id
LEFT JOIN
inspection_project_royalty AS royalty
ON node.project_id = royalty.project_id and orders.goods_id = royalty.goods_id
2024-11-08 13:28:58 +08:00
<where>
2025-02-15 18:01:18 +08:00
node.status = '2' AND info.status = '1' and node.deleted = 0
2024-11-08 13:28:58 +08:00
<if test="inspectionWorkNode.createTime != null">
AND node.create_time = #{inspectionWorkNode.createTime}
</if>
<if test="inspectionWorkNode.projectId != null">
AND node.project_id = #{inspectionWorkNode.projectId}
</if>
<if test="inspectionWorkNode.dealUserId != null">
AND node.deal_user_id = #{inspectionWorkNode.dealUserId}
</if>
<if test="inspectionWorkNode.dealUserName != null">
AND node.deal_user_name LIKE CONCAT('%', #{inspectionWorkNode.dealUserName} , '%')
</if>
<if test="inspectionWorkNode.rescueStartMonth != null">
2024-11-25 16:46:51 +08:00
AND DATE_FORMAT(node.create_time, '%Y-%m') = #{inspectionWorkNode.rescueStartMonth}
2024-11-08 13:28:58 +08:00
</if>
<if test="inspectionWorkNode.rescueStart != null and inspectionWorkNode.rescueEnd != null">
2024-11-25 16:46:51 +08:00
AND node.create_time BETWEEN #{inspectionWorkNode.rescueStart} AND #{inspectionWorkNode.rescueEnd}
2024-11-08 13:28:58 +08:00
</if>
</where>
2025-02-15 18:01:18 +08:00
group by node.deal_user_id
2024-11-08 13:28:58 +08:00
ORDER BY
node.create_time DESC;
</select>
2025-02-15 18:01:18 +08:00
<select id="getStaffCount" resultType="java.util.Map"
parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject">
SELECT iwn.deal_user_id, -- 处理人员ID
su.nickname, -- 处理人员名称
COUNT(iwn.deal_user_id) AS orderCount, -- 统计每个员工接单的数量
SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount -- 计算每个员工的总佣金
FROM inspection_work_node iwn
LEFT JOIN inspection_project AS proj -- Assuming this is the table for project details
ON iwn.project_id = proj.id
LEFT JOIN system_users su ON su.id = iwn.deal_user_id
LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id
LEFT JOIN order_info orders ON info.inspection_order_id = orders.id
LEFT JOIN inspection_project_royalty AS royalty ON iwn.project_id = royalty.project_id
AND orders.goods_id = royalty.goods_id
WHERE iwn.deleted = 0 -- 排除已删除的数据
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
AND iwn.`status` = 2
AND info.`status` = 1
GROUP BY iwn.deal_user_id -- 根据处理人员ID和名称进行分组
ORDER BY orderCount DESC; -- 根据接单数量进行降序排序
</select>
2024-11-04 15:07:18 +08:00
</mapper>