90 lines
4.4 KiB
XML
90 lines
4.4 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="com.bonus.cost.dao.ProjectCostDao">
|
|
|
|
<!-- 保存计算结果 -->
|
|
<insert id="saveCalculation" parameterType="com.bonus.cost.beans.ProjectCostCalculation" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO t_project_cost_calculation (
|
|
project_id, project_name, start_time, end_time, total_amount, create_time, create_user, del_flag
|
|
) VALUES (
|
|
#{projectId}, #{projectName}, #{startTime}, #{endTime}, #{totalAmount}, #{createTime}, #{createUser}, #{delFlag}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 保存计算结果明细 -->
|
|
<insert id="saveCalculationDetail" parameterType="com.bonus.cost.beans.ProjectCostCalculationDetail" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO t_project_cost_calculation_detail (
|
|
calculation_id, machine_type_id, machine_type_name, machine_model, machine_unit, price, current_count, amount
|
|
) VALUES (
|
|
#{calculationId}, #{machineTypeId}, #{machineTypeName}, #{machineModel}, #{machineUnit}, #{price}, #{currentCount}, #{amount}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 批量保存计算结果时间段 -->
|
|
<insert id="saveCalculationSegments" parameterType="java.util.List">
|
|
INSERT INTO t_project_cost_calculation_segment (
|
|
calculation_detail_id, start_time, end_time, days, count, amount
|
|
) VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(#{item.calculationDetailId}, #{item.startTime}, #{item.endTime}, #{item.days}, #{item.count}, #{item.amount})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 查询计算结果列表 -->
|
|
<select id="queryCalculationList" parameterType="com.bonus.cost.beans.ProjectCostCalculation" resultType="com.bonus.cost.beans.ProjectCostCalculation">
|
|
SELECT
|
|
id, project_id as projectId, project_name as projectName, start_time as startTime,
|
|
end_time as endTime, total_amount as totalAmount, create_time as createTime, create_user as createUser
|
|
FROM t_project_cost_calculation
|
|
WHERE del_flag = 0
|
|
<if test="projectId != null and projectId != ''">
|
|
AND project_id = #{projectId}
|
|
</if>
|
|
<if test="projectName != null and projectName != ''">
|
|
AND project_name LIKE CONCAT('%', #{projectName}, '%')
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
AND start_time >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
AND end_time <= #{endTime}
|
|
</if>
|
|
ORDER BY create_time DESC
|
|
</select>
|
|
|
|
<!-- 获取计算结果详情 -->
|
|
<select id="getCalculationById" parameterType="java.lang.Integer" resultType="com.bonus.cost.beans.ProjectCostCalculation">
|
|
SELECT
|
|
id, project_id as projectId, project_name as projectName, start_time as startTime,
|
|
end_time as endTime, total_amount as totalAmount, create_time as createTime, create_user as createUser
|
|
FROM t_project_cost_calculation
|
|
WHERE id = #{id} AND del_flag = 0
|
|
</select>
|
|
|
|
<!-- 查询计算结果明细 -->
|
|
<select id="queryCalculationDetails" parameterType="java.lang.Integer" resultType="com.bonus.cost.beans.ProjectCostCalculationDetail">
|
|
SELECT
|
|
id, calculation_id as calculationId, machine_type_id as machineTypeId, machine_type_name as machineTypeName,
|
|
machine_model as machineModel, machine_unit as machineUnit, price, current_count as currentCount, amount
|
|
FROM t_project_cost_calculation_detail
|
|
WHERE calculation_id = #{calculationId}
|
|
</select>
|
|
|
|
<!-- 查询计算结果时间段 -->
|
|
<select id="queryCalculationSegments" parameterType="java.lang.Integer" resultType="com.bonus.cost.beans.ProjectCostCalculationSegment">
|
|
SELECT
|
|
id, calculation_detail_id as calculationDetailId, start_time as startTime, end_time as endTime,
|
|
days, count, amount
|
|
FROM t_project_cost_calculation_segment
|
|
WHERE calculation_detail_id = #{detailId}
|
|
ORDER BY start_time
|
|
</select>
|
|
|
|
<!-- 删除计算结果(逻辑删除) -->
|
|
<update id="deleteCalculation" parameterType="java.lang.Integer">
|
|
UPDATE t_project_cost_calculation
|
|
SET del_flag = 1
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
</mapper> |