You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
705 lines
32 KiB
705 lines
32 KiB
<?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.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper">
|
|
|
|
<select id="palletListForPartNo" resultType="WmsLabelAndPalletData">
|
|
select b.site,a.pallet_id,b.part_no,sum(b.qty) as qty
|
|
from pallet_detail a ,handling_unit b, pallet c
|
|
<where>
|
|
and a.site = b.site
|
|
and a.serial_no = b.unit_id
|
|
and a.site = c.site
|
|
and a.pallet_id = c.pallet_id
|
|
and c.is_deleted = '0'
|
|
and (c.calling_flag IS NULL OR c.calling_flag != 'Y')
|
|
|
|
and a.site = #{site}
|
|
and b.reserve_flag != 'Y'
|
|
and b.in_stock_flag='Y'
|
|
and c.wcs_location is not null
|
|
<if test="warehouseId != null and warehouseId != ''">
|
|
and b.warehouse_id=#{warehouseId}
|
|
</if>
|
|
<if test="partNo != null and partNo != ''">
|
|
and a.part_no = #{partNo}
|
|
</if>
|
|
<if test="serialNo != null and serialNo != ''">
|
|
and a.serial_no = #{serialNo}
|
|
</if>
|
|
<if test="batchNo != null and batchNo != ''">
|
|
and b.batch_no = #{batchNo}
|
|
</if>
|
|
</where>
|
|
group by b.site, a.pallet_id, b.part_no
|
|
</select>
|
|
|
|
<select id="checkPalletTask" resultType="WmsTransportTask">
|
|
select id,site,task_no,source_type,source_bill_no,source_line_id,part_no,qty,batch_no,serial_no,from_location,to_location,
|
|
pallet_id,agv_code,priority,[status],wms_send_time,wcs_receive_time,start_time,complete_time,error_code,error_msg,
|
|
created_by,created_time,updated_time,wcs_task_id,finish_qty,wms_status
|
|
from wms_transport_task
|
|
where site = #{site}
|
|
and pallet_id = #{palletId}
|
|
and status not in ('结束','取消','失败')
|
|
</select>
|
|
|
|
<insert id="batchSaveTransportTask">
|
|
INSERT INTO wms_transport_task (
|
|
site, task_no, source_type, source_bill_no, source_line_id, part_no, qty,
|
|
batch_no, serial_no, from_location, to_location, pallet_id, agv_code,
|
|
priority, status, wms_send_time,
|
|
error_code, error_msg, created_by, created_time, wcs_task_id,
|
|
finish_qty, wms_status,item_no
|
|
) VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(
|
|
#{item.site}, #{item.taskNo}, #{item.sourceType}, #{item.sourceBillNo}, #{item.sourceLineId},
|
|
#{item.partNo}, #{item.qty}, #{item.batchNo}, #{item.serialNo}, #{item.fromLocation},
|
|
#{item.toLocation}, #{item.palletId}, #{item.agvCode}, #{item.priority}, #{item.status},
|
|
#{item.wmsSendTime},
|
|
#{item.errorCode}, #{item.errorMsg}, #{item.createdBy}, #{item.createdTime},
|
|
#{item.wcsTaskId}, #{item.finishQty}, '未执行', #{item.itemNo}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchSaveOrderTask">
|
|
INSERT INTO wms_order_task (
|
|
site, task_no, source_type, source_bill_no, source_line_id, part_no, qty,
|
|
batch_no, serial_no, from_location, to_location, pallet_id, agv_code,
|
|
priority, status, wms_send_time,
|
|
error_code, error_msg, created_by, created_time, wcs_task_id,
|
|
finish_qty, wms_status,item_no
|
|
) VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(
|
|
#{item.site}, #{item.taskNo}, #{item.sourceType}, #{item.sourceBillNo}, #{item.sourceLineId},
|
|
#{item.partNo}, #{item.qty}, #{item.batchNo}, #{item.serialNo}, #{item.fromLocation},
|
|
#{item.toLocation}, #{item.palletId}, #{item.agvCode}, #{item.priority}, #{item.status},
|
|
#{item.wmsSendTime},
|
|
#{item.errorCode}, #{item.errorMsg}, #{item.createdBy}, #{item.createdTime},
|
|
#{item.wcsTaskId}, #{item.finishQty}, #{item.wmsStatus}, #{item.itemNo}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
<insert id="batchSaveOrderTaskDetail">
|
|
INSERT INTO wms_order_task_detail (
|
|
site,task_no,item_no,seq_no,action_type,[comment],from_location,to_location,agv_code,[status],start_time,
|
|
error_code,error_msg,pallet_id,wms_status
|
|
) VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(
|
|
#{item.site}, #{item.taskNo}, #{item.itemNo}, #{item.seqNo}, #{item.actionType}, #{item.comment},
|
|
#{item.fromLocation}, #{item.toLocation}, #{item.agvCode}, #{item.status}, getdate(),
|
|
#{item.errorCode}, #{item.errorMsg}, #{item.palletId}, #{item.wmsStatus}
|
|
)
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- ==================== 打托相关SQL - AI制作 ==================== -->
|
|
|
|
<!-- 检查栈板是否存在并获取栈板信息 - AI制作 -->
|
|
<select id="getPalletInfo" resultType="java.util.Map">
|
|
SELECT pallet_id, pallet_type, status, location_code, site, calling_flag
|
|
FROM pallet
|
|
WHERE site = #{site} AND pallet_id = #{palletId} AND is_deleted = '0'
|
|
</select>
|
|
|
|
<!-- 获取栈板类型的位置信息 - AI制作 -->
|
|
<select id="getPalletTypePositions" resultType="java.lang.String">
|
|
SELECT position
|
|
FROM pallet_type_area
|
|
WHERE site = #{site} AND pallet_type = #{palletType}
|
|
ORDER BY position
|
|
</select>
|
|
|
|
<!-- 获取栈板明细 - AI制作 -->
|
|
<select id="getPalletDetails" resultType="java.util.Map">
|
|
SELECT a.site, a.pallet_id as palletId, a.position, a.layer, a.serial_no as serialNo, a.part_no as partNo,
|
|
a.create_date as createDate, a.create_by as createBy
|
|
FROM pallet_detail a
|
|
WHERE a.site = #{site} AND a.pallet_id = #{palletId}
|
|
<if test="position != null and position != ''">
|
|
AND a.position = #{position}
|
|
</if>
|
|
<if test="layer != null">
|
|
AND a.layer = #{layer}
|
|
</if>
|
|
ORDER BY a.position, a.layer, a.serial_no
|
|
</select>
|
|
<select id="getPalletDetailsData" resultType="PalletDetailData">
|
|
SELECT a.site, a.pallet_id as palletId, a.position, a.layer, a.serial_no as serialNo, a.part_no as partNo,
|
|
a.create_date as createDate, a.create_by as createBy,b.warehouse_id,b.location_id
|
|
|
|
FROM pallet_detail a left join handling_unit b on a.site = b.site and a.serial_no = b.unit_id
|
|
WHERE a.site = #{site} AND a.pallet_id = #{palletId}
|
|
|
|
</select>
|
|
|
|
<!-- 根据位置获取层数 - AI制作 -->
|
|
<select id="getLayersByPosition" resultType="java.lang.Integer">
|
|
SELECT DISTINCT layer
|
|
FROM pallet_detail
|
|
WHERE site = #{site} AND pallet_id = #{palletId} AND position = #{position}
|
|
ORDER BY layer
|
|
</select>
|
|
|
|
<!-- 验证标签 - AI制作 -->
|
|
<select id="validateLabel" resultType="java.util.Map">
|
|
SELECT site, unit_id as serialNo, part_no as partNo, qty, in_stock_flag as inStockFlag,
|
|
unit_type as labelType, batch_no as batchNo, warehouse_id as warehouseId,
|
|
location_id as locationId, remark, tid, epc
|
|
FROM handling_unit
|
|
WHERE site = #{site} AND unit_id = #{serialNo}
|
|
</select>
|
|
|
|
<!-- 获取栈板类型区域信息(用于校验层级规则) - AI制作 -->
|
|
<select id="getPalletTypeAreaInfo" resultType="java.util.Map">
|
|
SELECT site, pallet_type as palletType, position, position_desc as positionDesc
|
|
FROM pallet_type_area
|
|
WHERE site = #{site} AND pallet_type = #{palletType}
|
|
ORDER BY position
|
|
</select>
|
|
|
|
<!-- 获取栈板指定层的明细统计 - AI制作 -->
|
|
<select id="getPalletLayerStatistics" resultType="java.util.Map">
|
|
SELECT position, COUNT(*) as count
|
|
FROM pallet_detail
|
|
WHERE site = #{site} AND pallet_id = #{palletId} AND layer = #{layer}
|
|
GROUP BY position
|
|
</select>
|
|
|
|
<!-- 根据标签查找栈板信息 - AI制作 -->
|
|
<select id="findPalletByLabel" resultType="java.util.Map">
|
|
SELECT pallet_id as palletId, position, layer
|
|
FROM pallet_detail
|
|
WHERE site = #{site} AND serial_no = #{serialNo}
|
|
</select>
|
|
|
|
<select id="getNowStation" resultType="AgvStation">
|
|
SELECT TOP 1 b.station_code, b.location_code, b.warehouse_code
|
|
FROM pallet a
|
|
LEFT JOIN agv_station b ON a.location_code = b.station_code
|
|
WHERE a.site = #{site} AND a.pallet_id = #{palletId} AND a.is_deleted = '0'
|
|
</select>
|
|
|
|
<!-- 保存栈板明细 - AI制作 -->
|
|
<insert id="savePalletDetail">
|
|
INSERT INTO pallet_detail (site, pallet_id, position, layer, serial_no, part_no, create_date, create_by, wcs_flag)
|
|
VALUES (#{site}, #{palletId}, #{position}, #{layer}, #{serialNo}, #{partNo}, GETDATE(), #{createBy}, 1)
|
|
</insert>
|
|
|
|
<!-- 删除栈板明细 - AI制作 -->
|
|
<delete id="deletePalletDetail">
|
|
DELETE FROM pallet_detail
|
|
WHERE site = #{site} AND pallet_id = #{palletId} AND serial_no = #{serialNo}
|
|
</delete>
|
|
|
|
<!-- 根据条码删除栈板明细(不指定栈板ID) - AI制作 -->
|
|
<delete id="deletePalletDetailBySerialNo">
|
|
DELETE FROM pallet_detail
|
|
WHERE site = #{site} AND serial_no = #{serialNo}
|
|
</delete>
|
|
|
|
<!-- 获取指定位置已占用的层数(排除指定标签) - AI制作 -->
|
|
<select id="getOccupiedLayersExcludeSerial" resultType="java.lang.Integer">
|
|
SELECT DISTINCT layer
|
|
FROM pallet_detail
|
|
WHERE site = #{site}
|
|
AND pallet_id = #{palletId}
|
|
AND position = #{position}
|
|
AND serial_no != #{excludeSerialNo}
|
|
ORDER BY layer
|
|
</select>
|
|
|
|
<!-- 更新栈板明细位置 - AI制作 -->
|
|
<update id="updatePalletDetailPosition">
|
|
UPDATE pallet_detail
|
|
SET position = #{newPosition},
|
|
layer = #{newLayer},
|
|
wcs_flag = 1
|
|
WHERE site = #{site}
|
|
AND pallet_id = #{palletId}
|
|
AND serial_no = #{serialNo}
|
|
</update>
|
|
|
|
<!-- 更新栈板调用状态 - AI制作 -->
|
|
<update id="updatePalletCallingFlag">
|
|
UPDATE pallet
|
|
SET calling_flag = #{callingFlag},
|
|
updated_by = #{updatedBy},
|
|
updated_time = GETDATE()
|
|
WHERE site = #{site}
|
|
AND pallet_id = #{palletId}
|
|
</update>
|
|
|
|
<!-- 检查栈板是否正在被调用 - AI制作 -->
|
|
<select id="checkPalletCallingFlag" resultType="java.lang.String">
|
|
SELECT calling_flag
|
|
FROM pallet
|
|
WHERE site = #{site} AND pallet_id = #{palletId} AND is_deleted = '0'
|
|
</select>
|
|
|
|
<!-- 统计栈板明细数量 - AI制作 -->
|
|
<select id="countPalletDetails" resultType="java.lang.Integer">
|
|
SELECT COUNT(1)
|
|
FROM pallet_detail
|
|
WHERE site = #{site} AND pallet_id = #{palletId}
|
|
</select>
|
|
|
|
<!-- 更新栈板空栈板标记 - AI制作 -->
|
|
<update id="updatePalletEmptyFlag">
|
|
UPDATE pallet
|
|
SET empty_flag = #{emptyFlag},
|
|
updated_by = #{updatedBy},
|
|
updated_time = GETDATE()
|
|
WHERE site = #{site} AND pallet_id = #{palletId}
|
|
</update>
|
|
|
|
<!-- ==================== 运输任务相关SQL - AI制作 ==================== -->
|
|
|
|
<!-- 获取AGV站点列表 - AI制作 -->
|
|
<select id="getAgvStations" resultType="java.util.Map">
|
|
SELECT station_code as stationCode, station_name as stationName,
|
|
area_type as areaType, station_area as stationArea,
|
|
warehouse_code as warehouseCode, location_code as locationCode,
|
|
status_db as statusDb, status, station_id as stationId,
|
|
station_type as stationType
|
|
FROM agv_station
|
|
WHERE active = 'Y'
|
|
ORDER BY station_code
|
|
</select>
|
|
|
|
<!-- 根据目标区域查找第一个空闲站点 - AI制作 -->
|
|
<select id="findFirstFreeStationByArea" resultType="java.lang.String">
|
|
SELECT TOP 1 station_code
|
|
FROM agv_station
|
|
WHERE station_area = #{stationArea}
|
|
AND status_db = 0
|
|
AND active = 'Y'
|
|
AND station_type = '正式站点'
|
|
ORDER BY station_code
|
|
</select>
|
|
|
|
<!-- 根据起点站点获取可达目标站点 - AI制作 -->
|
|
<!-- 注:agv_route_config表已废弃,改为返回所有激活的站点(排除起始站点) -->
|
|
<select id="getTargetStationsByStart" resultType="java.util.Map">
|
|
SELECT station_code as stationCode, station_name as stationName,
|
|
status_db as statusDb, status
|
|
FROM agv_station
|
|
WHERE active = 'Y'
|
|
AND station_code != #{startStation}
|
|
ORDER BY station_code
|
|
</select>
|
|
|
|
<!-- 插入单个运输任务 - AI制作 -->
|
|
<insert id="insertTransportTask" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO wms_transport_task (
|
|
site, task_no, item_no, source_type, source_bill_no, source_line_id,
|
|
part_no, qty, batch_no, serial_no, from_location, to_location,
|
|
pallet_id, agv_code, priority, status, wms_send_time,
|
|
created_by, created_time, updated_time,wms_status
|
|
) VALUES (
|
|
#{site}, #{taskNo}, #{itemNo}, #{sourceType}, #{sourceBillNo}, #{sourceLineId},
|
|
#{partNo}, #{qty}, #{batchNo}, #{serialNo}, #{fromLocation}, #{toLocation},
|
|
#{palletId}, #{agvCode}, #{priority}, #{status}, #{wmsSendTime},
|
|
#{createdBy}, #{createdTime}, #{updatedTime},N'未执行'
|
|
)
|
|
</insert>
|
|
|
|
<insert id="insertOrderTask" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO wms_order_task (
|
|
site, task_no, item_no, source_type, source_bill_no, source_line_id,
|
|
part_no, qty, batch_no, serial_no, from_location, to_location,
|
|
pallet_id, agv_code, priority, status, wms_send_time,
|
|
created_by, created_time, updated_time
|
|
) VALUES (
|
|
#{site}, #{taskNo}, #{itemNo}, #{sourceType}, #{sourceBillNo}, #{sourceLineId},
|
|
#{partNo}, #{qty}, #{batchNo}, #{serialNo}, #{fromLocation}, #{toLocation},
|
|
#{palletId}, #{agvCode}, #{priority}, #{status}, #{wmsSendTime},
|
|
#{createdBy}, #{createdTime}, #{updatedTime}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 检查站点是否有栈板 - AI制作 -->
|
|
<select id="checkStationHasPallet" resultType="java.lang.Integer">
|
|
SELECT COUNT(1)
|
|
FROM pallet
|
|
WHERE site = #{site}
|
|
AND location_code = #{stationCode}
|
|
AND is_deleted = '0'
|
|
</select>
|
|
|
|
<!-- 获取站点的栈板ID - AI制作 -->
|
|
<select id="getPalletIdByStation" resultType="java.lang.String">
|
|
SELECT TOP 1 pallet_id
|
|
FROM pallet
|
|
WHERE site = #{site}
|
|
AND location_code = #{stationCode}
|
|
AND is_deleted = '0'
|
|
ORDER BY pallet_id
|
|
</select>
|
|
|
|
<!-- 根据ID查询运输任务 - AI制作 -->
|
|
<select id="getTransportTaskById" resultType="WmsTransportTask">
|
|
SELECT id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId,
|
|
part_no as partNo, qty, batch_no as batchNo, serial_no as serialNo,
|
|
from_location as fromLocation, to_location as toLocation,
|
|
pallet_id as palletId, agv_code as agvCode, priority, status,
|
|
wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime,
|
|
error_code as errorCode, error_msg as errorMsg,
|
|
created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId,
|
|
finish_qty as finishQty, wms_status as wmsStatus
|
|
FROM wms_transport_task
|
|
WHERE id = #{id}
|
|
</select>
|
|
|
|
<!-- 根据taskNo查询运输任务 - AI制作 -->
|
|
<select id="getTransportTaskByTaskNo" resultType="WmsTransportTask">
|
|
SELECT id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId,
|
|
part_no as partNo, qty, batch_no as batchNo, serial_no as serialNo,
|
|
from_location as fromLocation, to_location as toLocation,
|
|
pallet_id as palletId, agv_code as agvCode, priority, status,
|
|
wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime,
|
|
error_code as errorCode, error_msg as errorMsg,
|
|
created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId,
|
|
finish_qty as finishQty, wms_status as wmsStatus
|
|
FROM wms_transport_task
|
|
WHERE task_no = #{taskNo}
|
|
</select>
|
|
|
|
<!-- 更新运输任务状态 - AI制作 -->
|
|
<update id="updateTransportTaskStatus">
|
|
UPDATE wms_transport_task
|
|
SET status = #{status}, updated_time = GETDATE()
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!-- 根据taskNo更新运输任务状态 - AI制作 -->
|
|
<update id="updateTransportTaskStatusByTaskNo">
|
|
UPDATE wms_transport_task
|
|
SET status = #{status}, updated_time = GETDATE()
|
|
WHERE task_no = #{taskNo}
|
|
</update>
|
|
|
|
<!-- 根据站点代码获取站点信息 - AI制作 -->
|
|
<select id="getStationInfoByCode" resultType="java.util.Map">
|
|
SELECT station_code as stationCode, station_name as stationName,
|
|
warehouse_code as warehouseCode, location_code as locationCode,
|
|
area_type as areaType, active, status_db as statusDb, status,
|
|
station_id as stationId, station_type as stationType
|
|
FROM agv_station
|
|
WHERE station_code = #{stationCode}
|
|
</select>
|
|
|
|
<select id="getStationDataByCode" resultType="AgvStation">
|
|
SELECT station_code as stationCode, station_name as stationName,
|
|
warehouse_code as warehouseCode, location_code as locationCode,
|
|
area_type as areaType, active, status_db as statusDb, status,
|
|
station_id as stationId, station_type as stationType
|
|
FROM agv_station
|
|
WHERE station_code = #{stationCode}
|
|
</select>
|
|
|
|
<!-- 更新栈板明细的wcs_flag为0(已传输给WCS) - AI制作 -->
|
|
<update id="updatePalletDetailWcsFlag">
|
|
UPDATE pallet_detail
|
|
SET wcs_flag = 0
|
|
WHERE site = #{site}
|
|
AND pallet_id = #{palletId}
|
|
AND wcs_flag = 1
|
|
</update>
|
|
|
|
|
|
<select id="getPalletDetailsNewDetail" resultType="PalletDetailData">
|
|
select a.site,a.pallet_id,a.[position],a.layer,a.serial_no,a.part_no,a.create_date,a.create_by,a.wcs_flag,
|
|
b.part_desc,b.qty,b.batch_no,b.wdr,c.weight,b.length,b.width,c.height,c.is_robot_pick,um_id
|
|
,c.is_commonly_used, CONVERT(varchar(10),isnull( isnull(b.manufacture_date,b.receive_date),getdate()), 23) manufactureDateStr
|
|
from pallet_detail a
|
|
left join handling_unit b on a.site=b.site and a.serial_no=b.unit_id
|
|
left join part_attribute c on a.site=c.site and a.part_no=c.part_no
|
|
|
|
where a.wcs_flag = 1
|
|
</select>
|
|
<insert id="insertWmsTransportTaskDetail" >
|
|
insert into wms_transport_task_detail(
|
|
site,task_no,item_no,seq_no,action_type,[comment],from_location,to_location,agv_code,[status],start_time,
|
|
error_code,error_msg
|
|
) values (
|
|
#{site}, #{taskNo}, #{itemNo}, #{seqNo}, #{actionType}, #{comment}, #{fromLocation}, #{toLocation}, #{agvCode}, #{status}, #{startTime},
|
|
#{errorCode}, #{errorMsg}
|
|
)
|
|
</insert>
|
|
|
|
<insert id="insertWmsOrderTaskDetail" >
|
|
insert into wms_order_task_detail(
|
|
site,task_no,item_no,seq_no,action_type,[comment],from_location,to_location,agv_code,[status],start_time,
|
|
error_code,error_msg
|
|
) values (
|
|
#{site}, #{taskNo}, #{itemNo}, #{seqNo}, #{actionType}, #{comment}, #{fromLocation}, #{toLocation}, #{agvCode}, #{status}, #{startTime},
|
|
#{errorCode}, #{errorMsg}
|
|
)
|
|
</insert>
|
|
|
|
<select id="getMaxSeqNoForTaskDetail" resultType="Integer">
|
|
select isnull(max(seq_no),0)+1 from wms_transport_task_detail
|
|
where task_no=#{taskNo} and site=#{site} and item_no= 1
|
|
</select>
|
|
|
|
<update id="updateTransportTaskStatusForSiteAndNo">
|
|
update wms_transport_task set [status]=#{status} where site=#{site} and task_no=#{taskNo}
|
|
</update>
|
|
<update id="updateTransportTaskDetailStatusForId">
|
|
update wms_transport_task_detail set [status]=#{status} where id=#{id}
|
|
</update>
|
|
<select id="getTransportTaskDetailListWithStatus" resultType="WmsTransportTaskDetail">
|
|
select id,site,task_no as taskNo,item_no as itemNo,seq_no as seqNo,action_type as actionType,[comment],from_location as fromLocation,
|
|
to_location as toLocation,agv_code as agvCode,[status],start_time as startTime,
|
|
error_code as errorCode,error_msg as errorMsg
|
|
from wms_transport_task_detail
|
|
where site = #{site} and status in ('回调处理失败','已录入')
|
|
|
|
</select>
|
|
|
|
<!-- 查询指定状态的订单任务明细列表 - AI制作 -->
|
|
<select id="getOrderTaskDetailListWithStatus" resultType="WmsOrderTaskDetail">
|
|
select id,site,task_no as taskNo,item_no as itemNo,seq_no as seqNo,action_type as actionType,[comment],from_location as fromLocation,
|
|
to_location as toLocation,agv_code as agvCode,[status],start_time as startTime,
|
|
error_code as errorCode,error_msg as errorMsg
|
|
from wms_order_task_detail
|
|
where site = #{site} and status in ('处理失败','已录入')
|
|
</select>
|
|
|
|
<!-- 根据ID更新订单任务明细状态 - AI制作 -->
|
|
<update id="updateOrderTaskDetailStatusForId">
|
|
update wms_order_task_detail set [status]=#{status} where id=#{id}
|
|
</update>
|
|
|
|
<!-- 根据任务号获取栈板ID - AI制作 -->
|
|
<select id="getPalletIdByOrderTaskNo" resultType="String">
|
|
select pallet_id from wms_order_task where task_no = #{taskNo}
|
|
</select>
|
|
|
|
<!-- 根据栈板号和任务类型查找订单任务 - AI制作 -->
|
|
<select id="findOrderTaskByPalletAndType" resultType="WmsOrderTask">
|
|
select top 1 id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId, part_no as partNo,
|
|
qty, batch_no as batchNo, serial_no as serialNo, from_location as fromLocation,
|
|
to_location as toLocation, pallet_id as palletId, agv_code as agvCode,
|
|
priority, status, wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime, error_code as errorCode,
|
|
error_msg as errorMsg, created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId, finish_qty as finishQty,
|
|
wms_status as wmsStatus
|
|
from wms_order_task
|
|
where site = #{site}
|
|
and pallet_id = #{palletId}
|
|
and source_type = #{sourceType}
|
|
and status in ('已创建', '执行中', '已下发')
|
|
order by created_time desc
|
|
|
|
</select>
|
|
|
|
<!-- 获取订单任务明细的最大序号 - AI制作 -->
|
|
<select id="getMaxSeqNoForOrderTaskDetail" resultType="Integer">
|
|
select isnull(max(seq_no),0)+1 from wms_order_task_detail
|
|
where task_no=#{taskNo} and site=#{site}
|
|
</select>
|
|
|
|
<!-- 插入WCS回调任务 - AI制作 -->
|
|
<insert id="insertWcsCallbackTask" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO wcs_callback_task (
|
|
site, pallet_id, trans_type_desc, to_warehouse_id, to_location_id,
|
|
status, created_time, retry_count, remark, task_no, item_no, to_station
|
|
) VALUES (
|
|
#{site}, #{palletId}, #{transTypeDesc}, #{toWarehouseId}, #{toLocationId},
|
|
#{status}, #{createdTime}, #{retryCount}, #{remark}, #{taskNo}, #{itemNo}, #{toStation}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 查询指定状态的WCS回调任务列表(含超时恢复机制) - AI制作 -->
|
|
<select id="getWcsCallbackTaskListWithStatus" resultType="WcsCallbackTask">
|
|
select id, site, pallet_id as palletId, trans_type_desc as transTypeDesc,
|
|
to_warehouse_id as toWarehouseId, to_location_id as toLocationId,
|
|
status, created_time as createdTime, process_start_time as processStartTime,
|
|
process_end_time as processEndTime, error_msg as errorMsg,
|
|
retry_count as retryCount, remark,task_no,item_no,to_station
|
|
from wcs_callback_task
|
|
where site = #{site}
|
|
and (
|
|
status in ('已录入', '处理失败')
|
|
or (status = '处理中' and process_start_time < DATEADD(MINUTE, -10, GETDATE()))
|
|
)
|
|
and (retry_count is null or retry_count < 3)
|
|
order by created_time
|
|
</select>
|
|
|
|
<!-- 更新WCS回调任务状态 - AI制作 -->
|
|
<update id="updateWcsCallbackTaskStatus">
|
|
update wcs_callback_task
|
|
set status = #{status}
|
|
<if test="processStartTime != null">
|
|
, process_start_time = #{processStartTime}
|
|
</if>
|
|
<if test="processEndTime != null">
|
|
, process_end_time = #{processEndTime}
|
|
</if>
|
|
<if test="errorMsg != null">
|
|
, error_msg = #{errorMsg}
|
|
</if>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!-- 原子性更新WCS回调任务状态(乐观锁版本,防止重复处理) - AI制作 -->
|
|
<update id="updateWcsCallbackTaskStatusWithLock">
|
|
UPDATE wcs_callback_task
|
|
SET status = #{newStatus},
|
|
process_start_time = #{processStartTime}
|
|
WHERE id = #{id}
|
|
AND status = #{oldStatus}
|
|
</update>
|
|
|
|
<update id="updatePalletWcsLocation" >
|
|
update pallet set location_code = #{location},updated_by='wms_sys',updated_time=getdate()
|
|
where site = #{site} and pallet_id = #{palletId}
|
|
</update>
|
|
|
|
<!-- 更新WCS回调任务重试次数 - AI制作 -->
|
|
<update id="updateWcsCallbackTaskRetryCount">
|
|
update wcs_callback_task set retry_count = #{retryCount} where id = #{id}
|
|
</update>
|
|
|
|
<!-- 根据栈板ID和动作类型查找订单任务 - AI制作 -->
|
|
<select id="findOrderTasksByPalletAndActionType" resultType="WmsOrderTask">
|
|
select id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId, part_no as partNo,
|
|
qty, batch_no as batchNo, serial_no as serialNo, from_location as fromLocation,
|
|
to_location as toLocation, pallet_id as palletId, agv_code as agvCode,
|
|
priority, status, wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime, error_code as errorCode,
|
|
error_msg as errorMsg, created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId, finish_qty as finishQty,
|
|
wms_status as wmsStatus
|
|
from wms_order_task
|
|
where site = #{site}
|
|
and pallet_id = #{palletId}
|
|
and source_type = #{sourceType}
|
|
and status = #{status}
|
|
order by created_time desc
|
|
</select>
|
|
<select id="findOrderTasksByTaskNo" resultType="WmsOrderTask">
|
|
select id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId, part_no as partNo,
|
|
qty, batch_no as batchNo, serial_no as serialNo, from_location as fromLocation,
|
|
to_location as toLocation, pallet_id as palletId, agv_code as agvCode,
|
|
priority, status, wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime, error_code as errorCode,
|
|
error_msg as errorMsg, created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId, finish_qty as finishQty,
|
|
wms_status as wmsStatus
|
|
from wms_order_task
|
|
where site = #{site}
|
|
and task_no=#{taskNo}
|
|
order by created_time desc
|
|
</select>
|
|
|
|
<!-- 更新订单任务状态和WMS状态 - AI制作 -->
|
|
<update id="updateOrderTaskStatusAndWmsStatus">
|
|
update wms_order_task
|
|
set status = #{status}, wms_status = #{wmsStatus}
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!-- 根据任务号更新订单任务明细状态 - AI制作 -->
|
|
<update id="updateOrderTaskDetailStatusByTaskNo">
|
|
update wms_order_task_detail
|
|
set status = #{status} ,wms_status = #{wmsStatus}
|
|
where task_no = #{taskNo}
|
|
</update>
|
|
|
|
<!-- 查询立库调栈板出库的订单任务列表 - AI制作 -->
|
|
<select id="getWcsOrderTaskListForPalletOut" resultType="WmsOrderTask">
|
|
select id, site, task_no as taskNo, item_no as itemNo, source_type as sourceType,
|
|
source_bill_no as sourceBillNo, source_line_id as sourceLineId, part_no as partNo,
|
|
qty, batch_no as batchNo, serial_no as serialNo, from_location as fromLocation,
|
|
to_location as toLocation, pallet_id as palletId, agv_code as agvCode,
|
|
priority, status, wms_send_time as wmsSendTime, wcs_receive_time as wcsReceiveTime,
|
|
start_time as startTime, complete_time as completeTime, error_code as errorCode,
|
|
error_msg as errorMsg, created_by as createdBy, created_time as createdTime,
|
|
updated_time as updatedTime, wcs_task_id as wcsTaskId, finish_qty as finishQty,
|
|
wms_status as wmsStatus
|
|
from wms_order_task
|
|
where site = #{site}
|
|
and status = '已创建'
|
|
and source_type like '%出%'
|
|
and (wms_status is null or wms_status in ('未执行', '等待重试'))
|
|
order by priority desc, created_time asc
|
|
</select>
|
|
|
|
<!-- 更新订单任务错误信息 - AI制作 -->
|
|
<update id="updateOrderTaskErrorInfo">
|
|
update wms_order_task
|
|
set error_code = #{errorCode},
|
|
error_msg = #{errorMsg}
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!-- 更新AGV站点状态 - AI制作 -->
|
|
<update id="updateAgvStationStatus">
|
|
UPDATE agv_station
|
|
SET status_db = #{statusDb},
|
|
status = #{status}
|
|
WHERE station_code = #{stationCode}
|
|
</update>
|
|
|
|
<!-- 获取AGV站点状态 - AI制作 -->
|
|
<select id="getAgvStationStatus" resultType="Integer">
|
|
SELECT status_db
|
|
FROM agv_station
|
|
WHERE station_code = #{stationCode}
|
|
</select>
|
|
|
|
<!-- 获取栈板详细信息(包含palletType和autoSort以及托盘类型详情) - AI制作 -->
|
|
<select id="getPalletInfoWithTypeDetails" resultType="PalletData">
|
|
SELECT
|
|
p.site,
|
|
p.pallet_id AS palletId,
|
|
p.pallet_type AS palletType,
|
|
p.pallet_family AS palletFamily,
|
|
p.auto_sort AS autoSort,
|
|
p.sore_type AS soreType,
|
|
p.location_code AS locationCode,
|
|
p.wcs_location AS wcsLocation,
|
|
pt.type_desc AS typeDesc,
|
|
pt.wcs_auto_sort AS wcsAutoSort,
|
|
pt.wcs_pallet_type AS wcsPalletType,
|
|
pt.wcs_base_pallet_type AS wcsBasePalletType,
|
|
pt.wcs_sore_type AS wcsSoreType,
|
|
pt.max_layer AS maxLayer,
|
|
pf.pallet_family_desc AS palletFamilyDesc
|
|
FROM pallet p
|
|
LEFT JOIN pallet_type pt ON p.site = pt.site AND p.pallet_type = pt.pallet_type
|
|
LEFT JOIN pallet_family pf ON p.site = pf.site AND p.pallet_family = pf.pallet_family
|
|
WHERE p.site = #{site}
|
|
AND p.pallet_id = #{palletId}
|
|
AND p.is_deleted = '0'
|
|
</select>
|
|
|
|
<!-- 更新栈板类型和自动分拣标志 - AI制作 -->
|
|
<update id="updatePalletTypeAndAutoSort">
|
|
UPDATE pallet
|
|
SET pallet_type = #{palletType},
|
|
auto_sort = #{autoSort},
|
|
updated_time = GETDATE()
|
|
WHERE site = #{site}
|
|
AND pallet_id = #{palletId}
|
|
AND is_deleted = '0'
|
|
</update>
|
|
|
|
</mapper>
|