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

284 lines
17 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="com.bonus.digital.mapper.DayPlanMapper">
<insert id="addMonthlyPlan">
INSERT INTO tb_day_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="monthlyPlanId != null and monthlyPlanId != ''">monthly_plan_id,</if>
<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>
<if test="dayPlanType != null and dayPlanType != ''">day_plan_type,</if>
<if test="riskLevel != null and riskLevel != ''">risk_level,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="monthlyPlanId != null and monthlyPlanId != ''">#{monthlyPlanId},</if>
<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>
<if test="dayPlanType != null and dayPlanType != ''">#{dayPlanType},</if>
<if test="riskLevel != null and riskLevel != ''">#{riskLevel},</if>
</trim>
</insert>
<!-- 批量插入拟安排人员列表 -->
<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>
<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>
<if test="riskLevel != null and riskLevel != ''">risk_level = #{riskLevel},</if>
<if test="actualHighSub != null and actualHighSub != ''">actual_high_sub = #{actualHighSub},</if>
<if test="actualGroundSub != null and actualGroundSub != ''">actual_ground_sub = #{actualGroundSub},</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>
<delete id="delProposedPersonnel">
delete from tb_proposed_personnel where day_plan_id = #{dayPlanId}
</delete>
<select id="getDayPlanList" 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,
tdp.actual_high_sub AS actualHighSub,
tdp.actual_ground_sub AS actualGroundSub,
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 tdp.is_active = '1'
<!-- 原有查询条件保留,按需调整 -->
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
AND DATE_FORMAT(tdp.day_plan, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
</if>
<if test="dayPlanType != null and dayPlanType != ''">
AND tdp.day_plan_type = #{dayPlanType}
</if>
<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.inspection_station_id = #{inspectionStationId}
</if>
<if test="workContent!= null " >
AND tmp.work_content = #{workContent}
</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(tw.settlement_unit_price, 0) as s,
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="startDate != null and startDate != '' and endDate != null and endDate != ''">
AND DATE_FORMAT(tdp.day_plan, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
</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;
</select>
<select id="getProposedPersonnelList" resultType="com.bonus.digital.dao.ProposedPersonnelVo">
select tpp.day_plan_id,tpp.inspection_station_name,tpp.personnel_id,tpp.name,tpp.data_source,
tpc.personnel_classification_id, tpc.personnel_classification_name
from tb_proposed_personnel tpp
left join tb_personnel tp on tpp.personnel_id = tp.id
left join tb_personnel_classification tpc on tp.personnel_nature_id = tpc.personnel_classification_id
where tpp.day_plan_id = #{dayPlanId}
</select>
<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,
tdp.actual_high_sub AS actualHighSub,
tdp.actual_ground_sub AS actualGroundSub,
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 tdp.is_active = '1'
<if test="dayPlanId!= null " >
AND tdp.day_plan_id = #{dayPlanId}
</if>
<if test="dayPlan!= null " >
AND tdp.day_plan = #{dayPlan}
</if>
<if test="monthlyPlanId!= null " >
AND tdp.monthly_plan_id = #{monthlyPlanId}
</if>
</select>
</mapper>