108 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			108 lines
		
	
	
		
			4.8 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.InspectionWorkNodeMapper">
 | |
| 
 | |
|     <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}
 | |
|         ORDER BY wn.order_num ASC
 | |
|     </select>
 | |
|     <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,
 | |
|         node.update_time AS node_create_time,
 | |
|         node.update_time AS royalty_create_time
 | |
|         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
 | |
|         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
 | |
|         <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">
 | |
|                 AND DATE_FORMAT(info.end_time, '%Y-%m') = #{inspectionWorkNode.rescueStartMonth}
 | |
|             </if>
 | |
|             <if test="inspectionWorkNode.rescueStart != null and inspectionWorkNode.rescueEnd != null">
 | |
|                 AND info.end_time BETWEEN #{inspectionWorkNode.rescueStart} AND #{inspectionWorkNode.rescueEnd}
 | |
|             </if>
 | |
|         </where>
 | |
|         ORDER BY
 | |
|         info.end_time DESC;
 | |
|     </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
 | |
|         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
 | |
|         <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">
 | |
|                 AND DATE_FORMAT(info.end_time, '%Y-%m') = #{inspectionWorkNode.rescueStartMonth}
 | |
|             </if>
 | |
|             <if test="inspectionWorkNode.rescueStart != null and inspectionWorkNode.rescueEnd != null">
 | |
|                 AND info.end_time BETWEEN #{inspectionWorkNode.rescueStart} AND #{inspectionWorkNode.rescueEnd}
 | |
|             </if>
 | |
|         </where>
 | |
|         ORDER BY
 | |
|         node.create_time DESC;
 | |
|     </select>
 | |
| </mapper>
 | 
