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

264 lines
16 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=",">
2025-12-26 16:01:11 +08:00
<if test="monthlyPlanId != null and monthlyPlanId != ''">monthly_plan_id,</if>
2025-12-18 14:55:21 +08:00
<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-24 16:05:43 +08:00
<if test="riskLevel != null and riskLevel != ''">risk_level,</if>
2025-12-18 14:55:21 +08:00
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
2025-12-26 16:01:11 +08:00
<if test="monthlyPlanId != null and monthlyPlanId != ''">#{monthlyPlanId},</if>
2025-12-18 14:55:21 +08:00
<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-24 16:05:43 +08:00
<if test="riskLevel != null and riskLevel != ''">#{riskLevel},</if>
2025-12-18 14:55:21 +08:00
</trim>
</insert>
2025-12-29 10:01:06 +08:00
<!-- 批量插入拟安排人员列表 -->
<insert id="addProposedPersonnelList">
insert into tb_proposed_personnel (
day_plan_id,
inspection_station_name,
personnel_id,
name,
data_source
)
values
<!-- 核心遍历集合生成多条values语句 -->
<foreach collection="list" item="item" separator=",">
(
#{item.dayPlanId},
#{item.inspectionStationName},
#{item.personnelId},
#{item.name},
#{item.dataSource}
)
</foreach>
</insert>
2025-12-18 14:55:21 +08:00
<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>
2025-12-24 16:05:43 +08:00
<if test="riskLevel != null and riskLevel != ''">risk_level = #{riskLevel},</if>
2025-12-18 14:55:21 +08:00
</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-29 10:01:06 +08:00
<delete id="delProposedPersonnel">
delete from tb_proposed_personnel where day_plan_id = #{dayPlanId}
</delete>
2025-12-24 09:15:52 +08:00
2025-12-30 13:03:33 +08:00
<select id="getDayPlanList" resultType="com.bonus.digital.dao.DayPlanVo">
2025-12-18 14:55:21 +08:00
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,
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,
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,
2025-12-29 10:01:06 +08:00
tdp.risk_level AS riskLevel,
tmp.inspection_station_name AS inspectionStationName,
tpm.plan_major_name AS planMajorName,
tmp.project_name AS projectName,
tmp.work_content AS workContent
2025-12-18 14:55:21 +08:00
FROM
2025-12-24 09:15:52 +08:00
tb_day_plan tdp
2025-12-29 10:01:06 +08:00
left join tb_monthly_plan tmp on tdp.monthly_plan_id = tmp.monthly_plan_id
left join tb_plan_major tpm on tmp.plan_major_id = tpm.plan_major_id
where tdp.is_active = '1'
2025-12-24 09:15:52 +08:00
<!-- 原有查询条件保留,按需调整 -->
2025-12-30 13:03:33 +08:00
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
AND DATE_FORMAT(tdp.day_plan, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
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>
2025-12-30 13:03:33 +08:00
<if test="projectName!= null " >
AND tmp.project_name like concat('%', #{projectName}, '%')
</if>
<if test="planCompletionStatus!= null " >
AND tdp.plan_completion_status = #{planCompletionStatus}
</if>
<if test="inspectionStationId!= null " >
AND tmp.inspectionStationId = #{inspectionStationId}
</if>
2025-12-30 15:38:22 +08:00
<if test="workContent!= null " >
AND tmp.work_content = #{workContent}
</if>
2025-12-24 09:15:52 +08:00
</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'
2025-12-30 13:03:33 +08:00
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
AND DATE_FORMAT(tdp.day_plan, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
2025-12-24 09:15:52 +08:00
</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-29 10:01:06 +08:00
<select id="getProposedPersonnelList" resultType="com.bonus.digital.dao.ProposedPersonnelVo">
select day_plan_id,inspection_station_name,personnel_id,name,data_source
from tb_proposed_personnel where day_plan_id = #{dayPlanId}
</select>
2025-12-30 13:03:33 +08:00
<select id="getDayPlanById" resultType="com.bonus.digital.dao.DayPlanVo">
SELECT
tdp.day_plan_id AS dayPlanId,
tdp.monthly_plan_id AS monthlyPlanId,
tdp.day_plan AS dayPlan,
tdp.planned_workload AS plannedWorkload,
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,
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.risk_level AS riskLevel,
tmp.inspection_station_name AS inspectionStationName,
tpm.plan_major_name AS planMajorName,
tmp.project_name AS projectName,
tmp.work_content AS workContent
FROM
tb_day_plan tdp
left join tb_monthly_plan tmp on tdp.monthly_plan_id = tmp.monthly_plan_id
left join tb_plan_major tpm on tmp.plan_major_id = tpm.plan_major_id
where day_plan_id = #{dayPlanId}
</select>
2025-12-24 09:15:52 +08:00
2025-12-18 14:55:21 +08:00
</mapper>