2026-08-14 14:00:56 +08:00
|
|
|
<?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.code.nl.module.lms.dal.mysql.dailyplan.DailyPlanMapper">
|
|
|
|
|
|
|
|
|
|
<sql id="dailyPlanColumns">
|
|
|
|
|
daily_plan_id, plan_code, source_type, erp_order_code, manual_order_code,
|
|
|
|
|
plan_date, material_id, material_code, material_name, material_spec,
|
|
|
|
|
plan_qty, append_qty, stocked_qty, sleeved_qty, packing_info, sort_seq, weight,
|
|
|
|
|
order_status, stocking_status, sleeving_status,
|
|
|
|
|
previous_order_status, previous_stocking_status, previous_sleeving_status,
|
|
|
|
|
order_start_time, order_end_time, stocking_start_time, stocking_complete_time,
|
|
|
|
|
sleeving_start_time, sleeving_complete_time, version,
|
|
|
|
|
creator, create_time, updater, update_time, deleted, tenant_id
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="planOrOrderCodeCondition">
|
|
|
|
|
<if test="reqVO.planOrOrderCode != null and reqVO.planOrOrderCode != ''">
|
|
|
|
|
AND (plan_code LIKE CONCAT('%', #{reqVO.planOrOrderCode}, '%')
|
|
|
|
|
OR erp_order_code LIKE CONCAT('%', #{reqVO.planOrOrderCode}, '%')
|
|
|
|
|
OR manual_order_code LIKE CONCAT('%', #{reqVO.planOrOrderCode}, '%'))
|
|
|
|
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="materialKeywordCondition">
|
|
|
|
|
<if test="reqVO.materialKeyword != null and reqVO.materialKeyword != ''">
|
|
|
|
|
AND (material_code LIKE CONCAT('%', #{reqVO.materialKeyword}, '%')
|
|
|
|
|
OR material_name LIKE CONCAT('%', #{reqVO.materialKeyword}, '%')
|
|
|
|
|
OR material_spec LIKE CONCAT('%', #{reqVO.materialKeyword}, '%'))
|
|
|
|
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectManagementPage"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE deleted = b'0'
|
|
|
|
|
<include refid="planOrOrderCodeCondition"/>
|
|
|
|
|
<if test="reqVO.planDateStart != null">
|
|
|
|
|
AND plan_date >= #{reqVO.planDateStart}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="reqVO.planDateEnd != null">
|
|
|
|
|
AND plan_date <= #{reqVO.planDateEnd}
|
|
|
|
|
</if>
|
|
|
|
|
<include refid="materialKeywordCondition"/>
|
|
|
|
|
<if test="reqVO.sourceType != null">
|
|
|
|
|
AND source_type = #{reqVO.sourceType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="reqVO.orderStatus != null">
|
|
|
|
|
AND order_status = #{reqVO.orderStatus}
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY plan_date DESC, sort_seq ASC, daily_plan_id DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectWorkPage"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE deleted = b'0'
|
|
|
|
|
AND order_status = #{reqVO.orderStatus}
|
2026-08-14 14:03:30 +08:00
|
|
|
AND #{reqVO.orderStatus} IN (1, 3)
|
2026-08-14 14:00:56 +08:00
|
|
|
<include refid="planOrOrderCodeCondition"/>
|
|
|
|
|
<include refid="materialKeywordCondition"/>
|
|
|
|
|
ORDER BY sort_seq ASC, daily_plan_id ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectDailyPlanById"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectByErpOrderCode"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE erp_order_code = #{erpOrderCode}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectStockingCandidates"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE order_status = 1
|
|
|
|
|
AND stocking_status = 1
|
|
|
|
|
AND stocked_qty < plan_qty + append_qty
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
ORDER BY sort_seq ASC, daily_plan_id ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectSleevingCandidates"
|
|
|
|
|
resultType="cn.code.nl.module.lms.dal.dataobject.dailyplan.DailyPlanDO">
|
|
|
|
|
SELECT <include refid="dailyPlanColumns"/>
|
|
|
|
|
FROM lms_daily_plan
|
|
|
|
|
WHERE order_status = 1
|
|
|
|
|
AND sleeving_status = 1
|
|
|
|
|
AND sleeved_qty < plan_qty + append_qty
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
ORDER BY sort_seq ASC, daily_plan_id ASC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertDailyPlan">
|
|
|
|
|
INSERT INTO lms_daily_plan
|
|
|
|
|
(daily_plan_id, plan_code, source_type, erp_order_code, manual_order_code,
|
|
|
|
|
plan_date, material_id, material_code, material_name, material_spec,
|
|
|
|
|
plan_qty, append_qty, stocked_qty, sleeved_qty, packing_info, sort_seq, weight,
|
|
|
|
|
order_status, stocking_status, sleeving_status,
|
2026-08-14 14:07:54 +08:00
|
|
|
version, creator, updater)
|
2026-08-14 14:00:56 +08:00
|
|
|
VALUES
|
|
|
|
|
(#{plan.dailyPlanId}, #{plan.planCode}, #{plan.sourceType}, #{plan.erpOrderCode}, #{plan.manualOrderCode},
|
|
|
|
|
#{plan.planDate}, #{plan.materialId}, #{plan.materialCode}, #{plan.materialName}, #{plan.materialSpec},
|
2026-08-14 14:07:54 +08:00
|
|
|
#{plan.planQty}, 0, 0, 0, #{plan.packingInfo}, #{plan.sortSeq}, #{plan.weight},
|
|
|
|
|
0, 0, 0, 0, #{plan.creator}, #{plan.updater})
|
2026-08-14 14:00:56 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateNotStartedPlan">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET erp_order_code = #{plan.erpOrderCode},
|
|
|
|
|
manual_order_code = #{plan.manualOrderCode},
|
|
|
|
|
plan_date = #{plan.planDate},
|
|
|
|
|
material_id = #{plan.materialId},
|
|
|
|
|
material_code = #{plan.materialCode},
|
|
|
|
|
material_name = #{plan.materialName},
|
|
|
|
|
material_spec = #{plan.materialSpec},
|
|
|
|
|
plan_qty = #{plan.planQty},
|
|
|
|
|
packing_info = #{plan.packingInfo},
|
|
|
|
|
sort_seq = #{plan.sortSeq},
|
|
|
|
|
weight = #{plan.weight},
|
|
|
|
|
updater = #{plan.updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{plan.dailyPlanId}
|
|
|
|
|
AND version = #{plan.version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 0
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-08-14 14:07:54 +08:00
|
|
|
<update id="restoreOrderWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET order_status = previous_order_status,
|
|
|
|
|
previous_order_status = NULL,
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND version = #{version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 3
|
|
|
|
|
AND previous_order_status IS NOT NULL
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="restoreStockingWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET stocking_status = previous_stocking_status,
|
|
|
|
|
previous_stocking_status = NULL,
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND version = #{version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 1
|
|
|
|
|
AND stocking_status = 3
|
|
|
|
|
AND previous_stocking_status IS NOT NULL
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="restoreSleevingWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET sleeving_status = previous_sleeving_status,
|
|
|
|
|
previous_sleeving_status = NULL,
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND version = #{version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 1
|
|
|
|
|
AND sleeving_status = 3
|
|
|
|
|
AND previous_sleeving_status IS NOT NULL
|
|
|
|
|
</update>
|
|
|
|
|
|
2026-08-14 14:00:56 +08:00
|
|
|
<update id="updateStateWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
<set>
|
|
|
|
|
<if test="plan.orderStatus != null">order_status = #{plan.orderStatus},</if>
|
|
|
|
|
<if test="plan.stockingStatus != null">stocking_status = #{plan.stockingStatus},</if>
|
|
|
|
|
<if test="plan.sleevingStatus != null">sleeving_status = #{plan.sleevingStatus},</if>
|
|
|
|
|
<if test="plan.previousOrderStatus != null">previous_order_status = #{plan.previousOrderStatus},</if>
|
|
|
|
|
<if test="plan.previousStockingStatus != null">previous_stocking_status = #{plan.previousStockingStatus},</if>
|
|
|
|
|
<if test="plan.previousSleevingStatus != null">previous_sleeving_status = #{plan.previousSleevingStatus},</if>
|
|
|
|
|
<if test="plan.orderStartTime != null">order_start_time = #{plan.orderStartTime},</if>
|
|
|
|
|
<if test="plan.orderEndTime != null">order_end_time = #{plan.orderEndTime},</if>
|
|
|
|
|
<if test="plan.stockingStartTime != null">stocking_start_time = #{plan.stockingStartTime},</if>
|
|
|
|
|
<if test="plan.stockingCompleteTime != null">stocking_complete_time = #{plan.stockingCompleteTime},</if>
|
|
|
|
|
<if test="plan.sleevingStartTime != null">sleeving_start_time = #{plan.sleevingStartTime},</if>
|
|
|
|
|
<if test="plan.sleevingCompleteTime != null">sleeving_complete_time = #{plan.sleevingCompleteTime},</if>
|
|
|
|
|
<if test="plan.appendQty != null">append_qty = #{plan.appendQty},</if>
|
|
|
|
|
updater = #{plan.updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
</set>
|
|
|
|
|
WHERE daily_plan_id = #{plan.dailyPlanId}
|
|
|
|
|
AND version = #{plan.version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateSortWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET sort_seq = #{sortSeq}, updater = #{updater}, version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId} AND version = #{version} AND deleted = b'0'
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="updateWeightWithVersion">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET weight = #{weight}, updater = #{updater}, version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId} AND version = #{version} AND deleted = b'0'
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="increaseStockedQuantity">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET stocking_status = CASE
|
|
|
|
|
WHEN stocked_qty + #{incrementQty} = plan_qty + append_qty THEN 2
|
|
|
|
|
ELSE stocking_status END,
|
|
|
|
|
stocking_complete_time = CASE
|
|
|
|
|
WHEN stocked_qty + #{incrementQty} = plan_qty + append_qty THEN NOW()
|
|
|
|
|
ELSE stocking_complete_time END,
|
|
|
|
|
stocked_qty = stocked_qty + #{incrementQty},
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND version = #{version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 1
|
|
|
|
|
AND stocking_status = 1
|
2026-08-14 14:07:54 +08:00
|
|
|
AND #{incrementQty} > 0
|
2026-08-14 14:00:56 +08:00
|
|
|
AND stocked_qty + #{incrementQty} <= plan_qty + append_qty
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="increaseSleevedQuantity">
|
|
|
|
|
UPDATE lms_daily_plan
|
|
|
|
|
SET sleeving_status = CASE
|
|
|
|
|
WHEN sleeved_qty + #{incrementQty} = plan_qty + append_qty THEN 2
|
|
|
|
|
ELSE sleeving_status END,
|
|
|
|
|
sleeving_complete_time = CASE
|
|
|
|
|
WHEN sleeved_qty + #{incrementQty} = plan_qty + append_qty THEN NOW()
|
|
|
|
|
ELSE sleeving_complete_time END,
|
|
|
|
|
sleeved_qty = sleeved_qty + #{incrementQty},
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
version = version + 1
|
|
|
|
|
WHERE daily_plan_id = #{dailyPlanId}
|
|
|
|
|
AND version = #{version}
|
|
|
|
|
AND deleted = b'0'
|
|
|
|
|
AND order_status = 1
|
|
|
|
|
AND sleeving_status = 1
|
2026-08-14 14:07:54 +08:00
|
|
|
AND #{incrementQty} > 0
|
2026-08-14 14:00:56 +08:00
|
|
|
AND sleeved_qty + #{incrementQty} <= plan_qty + append_qty
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
</mapper>
|