ys_sms_sending_system/bonus-business/src/main/resources/mapper/DayPlanMapper.xml

241 lines
15 KiB
XML
Raw Normal View History

2025-12-18 14:55:21 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
2025-12-24 09:15:52 +08:00
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2025-12-18 14:55:21 +08:00
<mapper namespace="com.bonus.digital.mapper.DayPlanMapper">
<insert id="addMonthlyPlan">
INSERT INTO tb_day_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dayPlan != null and dayPlan != ''">day_plan,</if>
<if test="plannedWorkload != null and plannedWorkload != ''">planned_workload,</if>
<if test="proposedPersonnel != null and proposedPersonnel != ''">proposed_personnel,</if>
<if test="proposedProficientPersonnel != null and proposedProficientPersonnel != ''">proposed_proficient_personnel,</if>
<if test="proposedProficientDay != null and proposedProficientDay != ''">proposed_proficient_day,</if>
<if test="proposedAssistancePersonnel != null and proposedAssistancePersonnel != ''">proposed_assistance_personnel,</if>
<if test="proposedAssistanceDay != null and proposedAssistanceDay != ''">proposed_assistance_day,</if>
<if test="proposedLongTimeCar != null and proposedLongTimeCar != ''">proposed_long_time_car,</if>
<if test="proposedTemporaryCar != null and proposedTemporaryCar != ''">proposed_temporary_car,</if>
<if test="proposedSubCar != null and proposedSubCar != ''">proposed_sub_car,</if>
<if test="actualProficientPersonnel != null and actualProficientPersonnel != ''">actual_proficient_personnel,</if>
<if test="actualAssistancePersonnel != null and actualAssistancePersonnel != ''">actual_assistance_personnel,</if>
<if test="actualPersonnel != null and actualPersonnel != ''">actual_personnel,</if>
<if test="actualLongTimeCar != null and actualLongTimeCar != ''">actual_long_time_car,</if>
<if test="actualTemporaryCar != null and actualTemporaryCar != ''">actual_temporary_car,</if>
<if test="actualSubCar != null and actualSubCar != ''">actual_sub_car,</if>
<if test="actualWorkContent != null and actualWorkContent != ''">actual_work_content,</if>
<if test="actualWorkload != null and actualWorkload != ''">actual_workload,</if>
<if test="completionPercentage != null and completionPercentage != ''">completion_percentage,</if>
<if test="planCompletionStatus != null and planCompletionStatus != ''">plan_completion_status,</if>
<if test="planChanges != null and planChanges != ''">plan_changes,</if>
<if test="createUser != null and createUser != ''">create_user,</if>
<if test="createTime != null">create_time,</if>
<if test="status != null and status != ''">status,</if>
2025-12-18 18:22:27 +08:00
<if test="dayPlanType != null and dayPlanType != ''">day_plan_type,</if>
2025-12-18 14:55:21 +08:00
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="dayPlan != null and dayPlan != ''">#{dayPlan},</if>
<if test="plannedWorkload != null and plannedWorkload != ''">#{plannedWorkload},</if>
<if test="proposedPersonnel != null and proposedPersonnel != ''">#{proposedPersonnel},</if>
<if test="proposedProficientPersonnel != null and proposedProficientPersonnel != ''">#{proposedProficientPersonnel},</if>
<if test="proposedProficientDay != null and proposedProficientDay != ''">#{proposedProficientDay},</if>
<if test="proposedAssistancePersonnel != null and proposedAssistancePersonnel != ''">#{proposedAssistancePersonnel},</if>
<if test="proposedAssistanceDay != null and proposedAssistanceDay != ''">#{proposedAssistanceDay},</if>
<if test="proposedLongTimeCar != null and proposedLongTimeCar != ''">#{proposedLongTimeCar},</if>
<if test="proposedTemporaryCar != null and proposedTemporaryCar != ''">#{proposedTemporaryCar},</if>
<if test="proposedSubCar != null and proposedSubCar != ''">#{proposedSubCar},</if>
<if test="actualProficientPersonnel != null and actualProficientPersonnel != ''">#{actualProficientPersonnel},</if>
<if test="actualAssistancePersonnel != null and actualAssistancePersonnel != ''">#{actualAssistancePersonnel},</if>
<if test="actualPersonnel != null and actualPersonnel != ''">#{actualPersonnel},</if>
<if test="actualLongTimeCar != null and actualLongTimeCar != ''">#{actualLongTimeCar},</if>
<if test="actualTemporaryCar != null and actualTemporaryCar != ''">#{actualTemporaryCar},</if>
<if test="actualSubCar != null and actualSubCar != ''">#{actualSubCar},</if>
<if test="actualWorkContent != null and actualWorkContent != ''">#{actualWorkContent},</if>
<if test="actualWorkload != null and actualWorkload != ''">#{actualWorkload},</if>
<if test="completionPercentage != null and completionPercentage != ''">#{completionPercentage},</if>
<if test="planCompletionStatus != null and planCompletionStatus != ''">#{planCompletionStatus},</if>
<if test="planChanges != null and planChanges != ''">#{planChanges},</if>
<if test="createUser != null and createUser != ''">#{createUser},</if>
<if test="createTime != null">#{createTime},</if>
<if test="status != null and status != ''">#{status},</if>
2025-12-18 18:22:27 +08:00
<if test="dayPlanType != null and dayPlanType != ''">#{dayPlanType},</if>
2025-12-18 14:55:21 +08:00
</trim>
</insert>
<update id="updateDayPlan">
UPDATE tb_day_plan
<trim prefix="SET" suffixOverrides=",">
<if test="monthlyPlanId != null">monthly_plan_id = #{monthlyPlanId},</if>
<if test="dayPlan != null and dayPlan != ''">day_plan = #{dayPlan},</if>
<if test="plannedWorkload != null and plannedWorkload != ''">planned_workload = #{plannedWorkload},</if>
<if test="proposedPersonnel != null and proposedPersonnel != ''">proposed_personnel = #{proposedPersonnel},</if>
<if test="proposedProficientPersonnel != null and proposedProficientPersonnel != ''">proposed_proficient_personnel = #{proposedProficientPersonnel},</if>
<if test="proposedProficientDay != null and proposedProficientDay != ''">proposed_proficient_day = #{proposedProficientDay},</if>
<if test="proposedAssistancePersonnel != null and proposedAssistancePersonnel != ''">proposed_assistance_personnel = #{proposedAssistancePersonnel},</if>
<if test="proposedAssistanceDay != null and proposedAssistanceDay != ''">proposed_assistance_day = #{proposedAssistanceDay},</if>
<if test="proposedLongTimeCar != null and proposedLongTimeCar != ''">proposed_long_time_car = #{proposedLongTimeCar},</if>
<if test="proposedTemporaryCar != null and proposedTemporaryCar != ''">proposed_temporary_car = #{proposedTemporaryCar},</if>
<if test="proposedSubCar != null and proposedSubCar != ''">proposed_sub_car = #{proposedSubCar},</if>
<if test="actualProficientPersonnel != null and actualProficientPersonnel != ''">actual_proficient_personnel = #{actualProficientPersonnel},</if>
<if test="actualAssistancePersonnel != null and actualAssistancePersonnel != ''">actual_assistance_personnel = #{actualAssistancePersonnel},</if>
<if test="actualPersonnel != null and actualPersonnel != ''">actual_personnel = #{actualPersonnel},</if>
<if test="actualLongTimeCar != null and actualLongTimeCar != ''">actual_long_time_car = #{actualLongTimeCar},</if>
<if test="actualTemporaryCar != null and actualTemporaryCar != ''">actual_temporary_car = #{actualTemporaryCar},</if>
<if test="actualSubCar != null and actualSubCar != ''">actual_sub_car = #{actualSubCar},</if>
<if test="actualWorkContent != null and actualWorkContent != ''">actual_work_content = #{actualWorkContent},</if>
<if test="actualWorkload != null and actualWorkload != ''">actual_workload = #{actualWorkload},</if>
<if test="completionPercentage != null and completionPercentage != ''">completion_percentage = #{completionPercentage},</if>
<if test="planCompletionStatus != null and planCompletionStatus != ''">plan_completion_status = #{planCompletionStatus},</if>
<if test="planChanges != null and planChanges != ''">plan_changes = #{planChanges},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateUser != null and updateUser != ''">update_user = #{updateUser},</if>
<if test="status != null and status != ''">status = #{status},</if>
</trim>
WHERE day_plan_id = #{dayPlanId}
</update>
<delete id="delDayPlan">
update tb_day_plan set is_active = '0' where day_plan_id = #{dayPlanId}
</delete>
2025-12-24 09:15:52 +08:00
2025-12-18 14:55:21 +08:00
<select id="getDayPlanList" resultType="com.bonus.digital.dao.DayPlanVo">
SELECT
2025-12-24 09:15:52 +08:00
tdp.day_plan_id AS dayPlanId,
tdp.monthly_plan_id AS monthlyPlanId,
tdp.day_plan AS dayPlan,
tdp.planned_workload AS plannedWorkload,
-- 原有拟投入作业人员姓名通过子查询拼接替代主表存储的ID串
(SELECT GROUP_CONCAT(tp.NAME SEPARATOR ',')
FROM tb_personnel tp
WHERE FIND_IN_SET(tp.id, tdp.proposed_personnel)
AND tp.is_active = '1') AS proposedPersonnel,
-- 原有:拟投入作业人员数量
IF(tdp.proposed_personnel IS NULL OR tdp.proposed_personnel = '', 0,
LENGTH(tdp.proposed_personnel) - LENGTH(REPLACE(tdp.proposed_personnel, ',', '')) + 1)
AS proposedPersonnelNumber,
tdp.proposed_proficient_personnel AS proposedProficientPersonnel,
tdp.proposed_proficient_day AS proposedProficientDay,
tdp.proposed_assistance_personnel AS proposedAssistancePersonnel,
tdp.proposed_assistance_day AS proposedAssistanceDay,
tdp.proposed_long_time_car AS proposedLongTimeCar,
tdp.proposed_temporary_car AS proposedTemporaryCar,
tdp.proposed_sub_car AS proposedSubCar,
tdp.actual_proficient_personnel AS actualProficientPersonnel,
tdp.actual_assistance_personnel AS actualAssistancePersonnel,
-- 原有实际投入作业人员姓名通过子查询拼接替代主表存储的ID串
(SELECT GROUP_CONCAT(tp.NAME SEPARATOR ',')
FROM tb_personnel tp
WHERE FIND_IN_SET(tp.id, tdp.actual_personnel)
AND tp.is_active = '1') AS actualPersonnel,
tdp.actual_long_time_car AS actualLongTimeCar,
tdp.actual_temporary_car AS actualTemporaryCar,
tdp.actual_sub_car AS actualSubCar,
tdp.actual_work_content AS actualWorkContent,
tdp.actual_workload AS actualWorkload,
tdp.completion_percentage AS completionPercentage,
tdp.plan_completion_status AS planCompletionStatus,
tdp.plan_changes AS planChanges,
tdp.update_time AS updateTime,
tdp.is_active AS isActive,
tdp.create_user AS createUser,
tdp.create_time AS createTime,
tdp.update_user AS updateUser,
tdp.status AS status,
tdp.day_plan_type AS dayPlanType,
tdp.start_time AS startTime,
tdp.end_time AS endTime,
-- 新增拟投入高处作业人员data_source=2姓名 + 数量
(SELECT IFNULL(GROUP_CONCAT(tpp.personnel_name SEPARATOR ','), '')
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 2
AND tpp.is_active = '1') AS proposedHighPersonnelNames,
(SELECT COUNT(*)
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 2
AND tpp.is_active = '1') AS proposedHighPersonnelNum,
-- 新增拟投入地面作业人员data_source=3姓名 + 数量
(SELECT IFNULL(GROUP_CONCAT(tpp.personnel_name SEPARATOR ','), '')
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 3
AND tpp.is_active = '1') AS proposedGroundPersonnelNames,
(SELECT COUNT(*)
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 3
AND tpp.is_active = '1') AS proposedGroundPersonnelNum,
-- 新增实际投入高处作业人员data_source=4姓名 + 数量
(SELECT IFNULL(GROUP_CONCAT(tpp.personnel_name SEPARATOR ','), '')
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 4
AND tpp.is_active = '1') AS actualHighPersonnelNames,
(SELECT COUNT(*)
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 4
AND tpp.is_active = '1') AS actualHighPersonnelNum,
-- 新增实际投入地面作业人员data_source=5姓名 + 数量
(SELECT IFNULL(GROUP_CONCAT(tpp.personnel_name SEPARATOR ','), '')
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 5
AND tpp.is_active = '1') AS actualGroundPersonnelNames,
(SELECT COUNT(*)
FROM tb_proposed_personnel tpp
WHERE tpp.day_plan_id = tdp.day_plan_id
AND tpp.data_source = 5
AND tpp.is_active = '1') AS actualGroundPersonnelNum
2025-12-18 14:55:21 +08:00
FROM
2025-12-24 09:15:52 +08:00
tb_day_plan tdp
2025-12-18 18:22:27 +08:00
WHERE
2025-12-24 09:15:52 +08:00
tdp.is_active = '1'
<!-- 原有查询条件保留,按需调整 -->
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT(tdp.day_plan, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
2025-12-18 18:22:27 +08:00
</if>
2025-12-24 09:15:52 +08:00
<if test="dayPlanType != null and dayPlanType != ''">
AND tdp.day_plan_type = #{dayPlanType}
</if>
</select>
<select id="getWorkloadSummary" resultType="com.bonus.digital.dao.MonthlyPlanVo">
select
tmp.inspection_station_id,
tmp.inspection_station_name,
tw.workload_category_name,
IFNULL(tw.unit_price, 0) as unit_price,
IFNULL(SUM(tw.workload_num), 0) as total_workload,
IFNULL(SUM(tw.workload_num), 0) * IFNULL(tw.unit_price, 0) as total_amount
from tb_day_plan tdp
left join tb_monthly_plan tmp
on tmp.monthly_plan_id = tdp.monthly_plan_id
left join tb_workload tw
on tw.plan_id = tdp.day_plan_id
and tw.data_source = '1'
left join tb_plan_management pm
on pm.plan_management_id = tmp.plan_management_id
where tmp.is_active = '1'
<!-- 计划日期筛选 -->
<if test="startTime != null and startTime != ''">
AND tdp.day_plan &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND tdp.day_plan &lt;= #{endTime}
</if>
GROUP BY
tmp.inspection_station_id,
tmp.inspection_station_name,
tw.workload_category_name,
tw.unit_price
ORDER BY tmp.inspection_station_name ASC;
2025-12-18 14:55:21 +08:00
</select>
2025-12-24 09:15:52 +08:00
2025-12-18 14:55:21 +08:00
</mapper>