完成排产(测试过了)

This commit is contained in:
2026-03-08 16:02:44 +08:00
parent b660ddcc3e
commit 7736ac3311
125 changed files with 10418 additions and 15 deletions

View File

@@ -0,0 +1,230 @@
<?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.klp.aps.mapper.ApsAutoScheduleMapper">
<select id="selectPlanByIdForUpdate"
parameterType="long"
resultType="com.klp.aps.domain.row.ApsSchedulePlanRow">
SELECT
plan_id AS planId,
plan_code AS planCode,
version AS version,
order_id AS orderId,
status AS status,
start_date AS startDate,
end_date AS endDate
FROM wms_schedule_plan
WHERE plan_id = #{planId}
AND del_flag = 0
FOR UPDATE
</select>
<select id="selectOrderDetailsByOrderId"
parameterType="long"
resultType="com.klp.aps.domain.row.ApsOrderDetailRow">
SELECT
detail_id AS detailId,
product_id AS productId,
quantity AS quantity
FROM wms_order_detail
WHERE order_id = #{orderId}
AND del_flag = 0
ORDER BY detail_id ASC
</select>
<select id="selectPlanDetailsByPlanId"
parameterType="long"
resultType="com.klp.aps.domain.row.ApsPlanDetailRow">
SELECT
detail_id AS detailId,
task_id AS taskId,
line_id AS lineId,
product_id AS productId,
quantity AS quantity
FROM wms_schedule_plan_detail
WHERE plan_id = #{planId}
AND del_flag = 0
ORDER BY detail_id ASC
</select>
<select id="selectLineCandidatesByProductAndLine"
resultType="com.klp.aps.domain.row.ApsLineCapabilityRow">
SELECT
line_id AS lineId,
capacity_per_hour AS capacityPerHour,
setup_minutes AS setupMinutes,
priority AS priority
FROM wms_line_capability
WHERE is_enabled = 1
AND line_id = #{lineId}
AND (product_id = #{productId} OR product_id IS NULL)
ORDER BY CASE WHEN product_id = #{productId} THEN 0 ELSE 1 END, priority ASC, capability_id ASC
</select>
<select id="selectLineMetaById" resultType="com.klp.aps.domain.row.ApsLineMetaRow">
SELECT line_id AS lineId, line_name AS lineName
FROM wms_production_line
WHERE line_id = #{lineId}
LIMIT 1
</select>
<select id="selectProductMetaById" resultType="com.klp.aps.domain.row.ApsProductMetaRow">
SELECT product_id AS productId, product_name AS productName, specification AS specification, material AS material
FROM wms_product
WHERE product_id = #{productId}
LIMIT 1
</select>
<select id="selectAvailableShifts"
resultType="com.klp.aps.domain.row.ApsShiftSlotRow">
SELECT
cs.calendar_date AS calendarDate,
cs.line_id AS lineId,
cs.shift_id AS shiftId,
cs.planned_hours AS plannedHours,
st.start_time AS startTime,
st.end_time AS endTime,
st.cross_day AS crossDay,
st.efficiency_rate AS efficiencyRate
FROM wms_calendar_shift cs
JOIN wms_shift_template st ON st.shift_id = cs.shift_id
JOIN wms_calendar c ON c.calendar_date = cs.calendar_date
WHERE cs.line_id = #{lineId}
AND cs.status = 1
AND c.calendar_type = 1
AND cs.calendar_date BETWEEN #{startDate} AND #{endDate}
ORDER BY cs.calendar_date, st.start_time
</select>
<select id="selectPlanDetailId" resultType="long">
SELECT detail_id
FROM wms_schedule_plan_detail
WHERE plan_id = #{planId}
AND task_id = #{taskId}
AND del_flag = 0
ORDER BY detail_id ASC
LIMIT 1
</select>
<delete id="deleteUnlockedOperationsByPlanId">
DELETE FROM wms_schedule_operation
WHERE plan_id = #{planId}
AND locked_flag = 0
</delete>
<select id="selectFirstConflictEndTime" resultType="java.time.LocalDateTime">
SELECT end_time
FROM wms_schedule_operation
WHERE line_id = #{lineId}
AND status IN (0, 1, 3)
<if test="excludeOperationId != null">
AND operation_id <![CDATA[<>]]> #{excludeOperationId}
</if>
AND NOT (end_time <![CDATA[<=]]> #{startTime} OR start_time <![CDATA[>=]]> #{endTime})
ORDER BY end_time ASC
LIMIT 1
</select>
<select id="selectFirstHitLockEndTime" resultType="java.time.LocalDateTime">
SELECT l.lock_end_time
FROM wms_schedule_lock l
WHERE l.status = 1
<if test="planId != null">
AND (l.plan_id = #{planId} OR l.plan_id IS NULL)
</if>
AND (l.line_id = #{lineId} OR l.line_id IS NULL)
<if test="excludeOperationId != null">
AND (l.operation_id IS NULL OR l.operation_id <![CDATA[<>]]> #{excludeOperationId})
</if>
AND l.lock_start_time IS NOT NULL
AND l.lock_end_time IS NOT NULL
AND NOT (l.lock_end_time <![CDATA[<=]]> #{startTime} OR l.lock_start_time <![CDATA[>=]]> #{endTime})
ORDER BY l.lock_end_time ASC
LIMIT 1
</select>
<insert id="insertOperation"
parameterType="com.klp.aps.domain.entity.ApsScheduleOperationEntity"
useGeneratedKeys="true"
keyProperty="operationId"
keyColumn="operation_id">
INSERT INTO wms_schedule_operation
(
plan_id,
detail_id,
order_id,
order_detail_id,
product_id,
process_id,
line_id,
sequence_no,
plan_qty,
start_time,
end_time,
setup_minutes,
status,
locked_flag,
remark,
create_by,
update_by
)
VALUES
(
#{planId},
#{detailId},
#{orderId},
#{orderDetailId},
#{productId},
#{processId},
#{lineId},
#{sequenceNo},
#{planQty},
#{startTime},
#{endTime},
#{setupMinutes},
#{status},
#{lockedFlag},
#{remark},
#{createBy},
#{updateBy}
)
</insert>
<insert id="insertChangeLog"
parameterType="com.klp.aps.domain.entity.ApsScheduleChangeLogEntity"
useGeneratedKeys="true"
keyProperty="logId"
keyColumn="log_id">
INSERT INTO wms_schedule_change_log
(
operation_id,
change_type,
before_value,
after_value,
change_reason,
change_by
)
VALUES
(
#{operationId},
#{changeType},
#{beforeValue},
#{afterValue},
#{changeReason},
#{changeBy}
)
</insert>
<update id="updatePlanStatus">
UPDATE wms_schedule_plan
SET status = #{status},
update_by = #{updateBy},
update_time = CURRENT_TIMESTAMP
WHERE plan_id = #{planId}
AND del_flag = 0
</update>
</mapper>

View File

@@ -0,0 +1,48 @@
<?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.klp.aps.mapper.ApsCalendarMapper">
<resultMap type="com.klp.aps.domain.entity.ApsCalendarEntity" id="ApsCalendarResult">
<result property="calendarId" column="calendar_id"/>
<result property="calendarDate" column="calendar_date"/>
<result property="calendarType" column="calendar_type"/>
<result property="factoryCode" column="factory_code"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectCalendarVo">
SELECT calendar_id, calendar_date, calendar_type, factory_code, remark,
create_by, create_time, update_by, update_time
FROM wms_calendar
</sql>
<select id="selectCalendarList" parameterType="com.klp.aps.domain.entity.ApsCalendarEntity" resultMap="ApsCalendarResult">
<include refid="selectCalendarVo"/>
<where>
<if test="calendarDate != null">
AND calendar_date = #{calendarDate}
</if>
<if test="calendarType != null">
AND calendar_type = #{calendarType}
</if>
<if test="factoryCode != null and factoryCode != ''">
AND factory_code = #{factoryCode}
</if>
</where>
ORDER BY calendar_date DESC
</select>
<select id="selectByDateAndFactory" resultMap="ApsCalendarResult">
<include refid="selectCalendarVo"/>
WHERE calendar_date = #{calendarDate}
AND factory_code = #{factoryCode}
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,23 @@
<?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.klp.aps.mapper.ApsCalendarShiftMapper">
<select id="selectByDateLineAndShift" resultType="com.klp.aps.domain.entity.ApsCalendarShiftEntity">
SELECT *
FROM wms_calendar_shift
WHERE calendar_date = #{calendarDate}
AND line_id = #{lineId}
AND shift_id = #{shiftId}
AND del_flag = 0
LIMIT 1
</select>
<select id="selectDistinctLineIds" resultType="java.lang.Long">
SELECT DISTINCT line_id
FROM wms_production_line
WHERE del_flag = 0
</select>
</mapper>

View File

@@ -0,0 +1,50 @@
<?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.klp.aps.mapper.ApsGanttMapper">
<select id="selectGanttItems"
parameterType="com.klp.aps.domain.dto.ApsGanttQueryReq"
resultType="com.klp.aps.domain.vo.ApsGanttItemVo">
SELECT
o.operation_id AS operationId,
o.plan_id AS planId,
p.plan_code AS planCode,
o.order_id AS orderId,
o.order_detail_id AS orderDetailId,
o.product_id AS productId,
pr.product_name AS productName,
pr.material AS material,
pr.specification AS specification,
o.process_id AS processId,
ps.process_name AS processName,
o.line_id AS lineId,
l.line_name AS lineName,
o.sequence_no AS sequenceNo,
o.plan_qty AS planQty,
o.start_time AS startTime,
o.end_time AS endTime,
o.status AS status,
o.locked_flag AS lockedFlag
FROM wms_schedule_operation o
LEFT JOIN wms_schedule_plan p ON p.plan_id = o.plan_id
LEFT JOIN wms_product pr ON pr.product_id = o.product_id
LEFT JOIN wms_processe ps ON ps.process_id = o.process_id
LEFT JOIN wms_production_line l ON l.line_id = o.line_id
WHERE o.end_time <![CDATA[>=]]> #{queryStart}
AND o.start_time <![CDATA[<=]]> #{queryEnd}
<if test="lineId != null">
AND o.line_id = #{lineId}
</if>
<if test="planId != null">
AND o.plan_id = #{planId}
</if>
<if test="orderId != null">
AND o.order_id = #{orderId}
</if>
ORDER BY o.line_id, o.start_time
</select>
</mapper>

View File

@@ -0,0 +1,17 @@
<?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.klp.aps.mapper.ApsLineCapabilityMapper">
<select id="selectByLineProductAndProcess" resultType="com.klp.aps.domain.entity.ApsLineCapabilityEntity">
SELECT *
FROM wms_line_capability
WHERE line_id = #{lineId}
AND (product_id = #{productId} OR (product_id IS NULL AND #{productId} IS NULL))
AND (process_id = #{processId} OR (process_id IS NULL AND #{processId} IS NULL))
AND del_flag = 0
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,49 @@
<?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.klp.aps.mapper.ApsLockMapper">
<insert id="insertLock"
parameterType="com.klp.aps.domain.entity.ApsScheduleLockEntity"
useGeneratedKeys="true"
keyProperty="lockId"
keyColumn="lock_id">
INSERT INTO wms_schedule_lock
(
lock_type,
plan_id,
line_id,
operation_id,
lock_start_time,
lock_end_time,
lock_reason,
status,
create_by,
update_by
)
VALUES
(
#{lockType},
#{planId},
#{lineId},
#{operationId},
#{lockStartTime},
#{lockEndTime},
#{lockReason},
#{status},
#{createBy},
#{updateBy}
)
</insert>
<update id="updateLockStatus">
UPDATE wms_schedule_lock
SET status = #{status},
update_by = #{updateBy},
update_time = CURRENT_TIMESTAMP
WHERE lock_id = #{lockId}
</update>
</mapper>

View File

@@ -0,0 +1,93 @@
<?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.klp.aps.mapper.ApsOperationMapper">
<resultMap id="ApsScheduleOperationMap"
type="com.klp.aps.domain.entity.ApsScheduleOperationEntity">
<id property="operationId" column="operation_id"/>
<result property="planId" column="plan_id"/>
<result property="detailId" column="detail_id"/>
<result property="orderId" column="order_id"/>
<result property="orderDetailId" column="order_detail_id"/>
<result property="productId" column="product_id"/>
<result property="processId" column="process_id"/>
<result property="lineId" column="line_id"/>
<result property="sequenceNo" column="sequence_no"/>
<result property="planQty" column="plan_qty"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="setupMinutes" column="setup_minutes"/>
<result property="status" column="status"/>
<result property="lockedFlag" column="locked_flag"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
</resultMap>
<select id="selectByIdForUpdate"
parameterType="long"
resultMap="ApsScheduleOperationMap">
SELECT
operation_id,
plan_id,
detail_id,
order_id,
order_detail_id,
product_id,
process_id,
line_id,
sequence_no,
plan_qty,
start_time,
end_time,
setup_minutes,
status,
locked_flag,
remark,
create_by,
update_by
FROM wms_schedule_operation
WHERE operation_id = #{operationId}
FOR UPDATE
</select>
<update id="updateSlot"
parameterType="com.klp.aps.domain.entity.ApsScheduleOperationEntity">
UPDATE wms_schedule_operation
SET line_id = #{lineId},
start_time = #{startTime},
end_time = #{endTime},
update_by = #{updateBy},
update_time = CURRENT_TIMESTAMP
WHERE operation_id = #{operationId}
</update>
<insert id="insertChangeLog"
parameterType="com.klp.aps.domain.entity.ApsScheduleChangeLogEntity"
useGeneratedKeys="true"
keyProperty="logId"
keyColumn="log_id">
INSERT INTO wms_schedule_change_log
(
operation_id,
change_type,
before_value,
after_value,
change_reason,
change_by
)
VALUES
(
#{operationId},
#{changeType},
#{beforeValue},
#{afterValue},
#{changeReason},
#{changeBy}
)
</insert>
</mapper>

View File

@@ -0,0 +1,197 @@
<?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.klp.aps.mapper.ApsPlanMapper">
<select id="selectOrderDetailsByOrderId"
parameterType="long"
resultType="com.klp.aps.domain.row.ApsOrderDetailRow">
SELECT
detail_id AS detailId,
product_id AS productId,
quantity AS quantity
FROM wms_order_detail
WHERE order_id = #{orderId}
AND (del_flag = 0 OR del_flag IS NULL)
ORDER BY detail_id ASC
</select>
<select id="selectCrmOrderById" resultType="com.klp.aps.domain.row.ApsCrmOrderRow">
SELECT
order_id AS orderId,
order_code AS orderCode,
customer_id AS customerId,
salesman AS salesman,
order_amount AS orderAmount,
remark AS remark
FROM crm_order
WHERE order_id = #{crmOrderId}
AND del_flag = 0
LIMIT 1
</select>
<select id="selectCrmOrderItemsByOrderId" resultType="com.klp.aps.domain.row.ApsCrmOrderItemRow">
SELECT
item_id AS itemId,
order_id AS orderId,
product_type AS productType,
product_num AS productNum,
contract_price AS contractPrice,
remark AS remark
FROM crm_order_item
WHERE order_id = #{crmOrderId}
AND del_flag = 0
ORDER BY item_id ASC
</select>
<select id="selectWmsOrderByCode" resultType="com.klp.aps.domain.row.ApsWmsOrderRow">
SELECT order_id AS orderId, order_code AS orderCode
FROM wms_order
WHERE order_code = #{orderCode}
AND del_flag = 0
LIMIT 1
</select>
<insert id="insertWmsOrder" parameterType="com.klp.aps.domain.dto.ApsWmsOrderCreateReq">
INSERT INTO wms_order
(
order_code,
customer_id,
customer_name,
sales_manager,
order_status,
remark,
tax_amount,
no_tax_amount,
del_flag,
create_by,
update_by
)
VALUES
(
#{orderCode},
#{customerId},
#{customerName},
#{salesManager},
#{orderStatus},
#{remark},
#{taxAmount},
#{noTaxAmount},
0,
#{createBy},
#{updateBy}
)
</insert>
<insert id="insertWmsOrderDetail" parameterType="com.klp.aps.domain.dto.ApsWmsOrderDetailCreateReq">
INSERT INTO wms_order_detail
(
order_id,
product_id,
quantity,
unit,
remark,
tax_price,
no_tax_price,
group_id,
del_flag,
create_by,
update_by
)
VALUES
(
#{orderId},
#{productId},
#{quantity},
#{unit},
#{remark},
#{taxPrice},
#{noTaxPrice},
#{groupId},
IFNULL(#{delFlag}, 0),
#{createBy},
#{updateBy}
)
</insert>
<select id="selectAnyProductionLineId" resultType="long">
SELECT line_id
FROM wms_production_line
WHERE del_flag = 0
ORDER BY line_id ASC
LIMIT 1
</select>
<insert id="insertSchedulePlan"
parameterType="com.klp.aps.domain.entity.ApsSchedulePlanEntity"
useGeneratedKeys="true"
keyProperty="planId"
keyColumn="plan_id">
INSERT INTO wms_schedule_plan
(
plan_code,
version,
order_id,
status,
remark,
del_flag,
create_by,
update_by,
priority,
start_date,
end_date
)
VALUES
(
#{planCode},
#{version},
#{orderId},
#{status},
#{remark},
#{delFlag},
#{createBy},
#{updateBy},
#{priority},
#{startDate},
#{endDate}
)
</insert>
<insert id="insertSchedulePlanDetail"
parameterType="com.klp.aps.domain.entity.ApsSchedulePlanDetailEntity"
useGeneratedKeys="true"
keyProperty="detailId"
keyColumn="detail_id">
INSERT INTO wms_schedule_plan_detail
(
plan_id,
line_id,
task_id,
product_id,
quantity,
start_date,
end_date,
remark,
del_flag,
create_by,
update_by
)
VALUES
(
#{planId},
#{lineId},
#{taskId},
#{productId},
#{quantity},
#{startDate},
#{endDate},
#{remark},
#{delFlag},
#{createBy},
#{updateBy}
)
</insert>
</mapper>

View File

@@ -0,0 +1,143 @@
<?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.klp.aps.mapper.ApsScheduleSheetMapper">
<select id="selectSheetRows"
parameterType="com.klp.aps.domain.dto.ApsScheduleSheetQueryReq"
resultType="com.klp.aps.domain.vo.ApsScheduleSheetRowVo">
SELECT
o.operation_id AS operationId,
o.line_id AS lineId,
l.line_name AS lineName,
o.plan_id AS planId,
p.plan_code AS planCode,
o.order_id AS orderId,
ord.order_code AS orderCode,
ord.sales_manager AS salesman,
ord.customer_name AS customerName,
o.product_id AS productId,
pr.product_name AS productName,
pr.material AS material,
pr.specification AS specification,
o.process_id AS processId,
ps.process_name AS processName,
o.plan_qty AS planQty,
DATE_FORMAT(o.start_time, '%Y-%m-%d %H:%i:%s') AS startTime,
DATE_FORMAT(o.end_time, '%Y-%m-%d %H:%i:%s') AS endTime,
-- 原料钢卷信息:优先来自 wms_schedule_operation_coil + wms_material_coil
COALESCE(
CAST(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawMaterialId')) AS UNSIGNED),
MAX(soc.coil_id)
) AS rawMaterialId,
COALESCE(
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawCoilNos')), ''),
GROUP_CONCAT(DISTINCT COALESCE(mc.current_coil_no, mc.enter_coil_no) ORDER BY COALESCE(mc.current_coil_no, mc.enter_coil_no) SEPARATOR ',')
) AS rawCoilNos,
COALESCE(
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawLocation')), ''),
GROUP_CONCAT(DISTINCT aw.actual_warehouse_name ORDER BY aw.actual_warehouse_name SEPARATOR ',')
) AS rawLocation,
COALESCE(
CAST(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawNetWeight')) AS DECIMAL(18,4)),
COALESCE(SUM(mc.net_weight), 0)
) AS rawNetWeight,
COALESCE(
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawPackaging')), ''),
MAX(mc.packaging_requirement)
) AS rawPackaging,
COALESCE(
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawEdgeReq')), ''),
MAX(mc.trimming_requirement)
) AS rawEdgeReq,
COALESCE(
NULLIF(JSON_UNQUOTE(JSON_EXTRACT(MAX(CASE WHEN JSON_VALID(o.remark) THEN o.remark ELSE NULL END), '$.rawCoatingType')), ''),
MAX(mc.coating_type)
) AS rawCoatingType
FROM wms_schedule_operation o
LEFT JOIN wms_schedule_plan p ON p.plan_id = o.plan_id
LEFT JOIN wms_order ord ON ord.order_id = o.order_id
LEFT JOIN wms_product pr ON pr.product_id = o.product_id
LEFT JOIN wms_processe ps ON ps.process_id = o.process_id
LEFT JOIN wms_production_line l ON l.line_id = o.line_id
LEFT JOIN wms_schedule_operation_coil soc ON soc.operation_id = o.operation_id AND soc.del_flag = 0
LEFT JOIN wms_material_coil mc ON mc.coil_id = soc.coil_id AND mc.del_flag = 0
LEFT JOIN wms_actual_warehouse aw ON aw.actual_warehouse_id = mc.actual_warehouse_id AND aw.del_flag = 0
WHERE o.end_time <![CDATA[>=]]> #{queryStart}
AND o.start_time <![CDATA[<=]]> #{queryEnd}
<if test="lineId != null">
AND o.line_id = #{lineId}
</if>
<if test="planId != null and planId != ''">
AND (
p.plan_code = #{planId}
OR (#{planId} REGEXP '^[0-9]+$' AND o.plan_id = CAST(#{planId} AS UNSIGNED))
)
</if>
<if test="orderId != null and orderId != ''">
AND (
ord.order_code = #{orderId}
OR (#{orderId} REGEXP '^[0-9]+$' AND o.order_id = CAST(#{orderId} AS UNSIGNED))
)
</if>
GROUP BY
o.operation_id,
o.line_id,
l.line_name,
o.plan_id,
p.plan_code,
o.order_id,
ord.order_code,
ord.sales_manager,
ord.customer_name,
o.product_id,
pr.product_name,
o.process_id,
ps.process_name,
o.plan_qty,
o.start_time,
o.end_time
ORDER BY o.line_id, o.start_time
</select>
<update id="deleteOperationCoils">
UPDATE wms_schedule_operation_coil
SET del_flag = 1,
update_by = #{updateBy},
update_time = CURRENT_TIMESTAMP
WHERE operation_id = #{operationId}
AND del_flag = 0
</update>
<insert id="insertOperationCoil">
INSERT INTO wms_schedule_operation_coil
(
operation_id,
coil_id,
create_by,
update_by,
del_flag
)
VALUES
(
#{operationId},
#{coilId},
#{createBy},
#{createBy},
0
)
</insert>
<update id="updateOperationSupplement">
UPDATE wms_schedule_operation
SET remark = #{remarkJson},
update_by = #{updateBy},
update_time = CURRENT_TIMESTAMP
WHERE operation_id = #{operationId}
</update>
</mapper>

View File

@@ -0,0 +1,15 @@
<?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.klp.aps.mapper.ApsShiftTemplateMapper">
<select id="selectByShiftCode" resultType="com.klp.aps.domain.entity.ApsShiftTemplateEntity">
SELECT *
FROM wms_shift_template
WHERE shift_code = #{shiftCode}
AND del_flag = 0
LIMIT 1
</select>
</mapper>