<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
~
|
~ Copyright (c) 2018-2025, ztt All rights reserved.
|
~
|
~ Redistribution and use in source and binary forms, with or without
|
~ modification, are permitted provided that the following conditions are met:
|
~
|
~ Redistributions of source code must retain the above copyright notice,
|
~ this list of conditions and the following disclaimer.
|
~ Redistributions in binary form must reproduce the above copyright
|
~ notice, this list of conditions and the following disclaimer in the
|
~ documentation and/or other materials provided with the distribution.
|
~ Neither the name of the pig4cloud.com developer nor the names of its
|
~ contributors may be used to endorse or promote products derived from
|
~ this software without specific prior written permission.
|
~ Author: ztt
|
~
|
-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chinaztt.mes.warehouse.mapper.PackagingItemMapper">
|
|
<resultMap id="packagingItemMap" type="com.chinaztt.mes.warehouse.entity.PackagingItem">
|
<id property="id" column="id"/>
|
<result property="partId" column="part_id"/>
|
<result property="stockId" column="stock_id"/>
|
<result property="outBatchNo" column="out_batch_no"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="packageQty" column="package_qty"/>
|
<result property="createTime" column="create_time"/>
|
<result property="packagingId" column="packaging_id"/>
|
<result property="specs" column="specs"/>
|
<result property="locationId" column="location_id"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="inLocationId" column="in_location_id"/>
|
<result property="theoryWeight" column="theory_weight"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
</resultMap>
|
<resultMap id="packagingItemMapDTO" type="com.chinaztt.mes.warehouse.dto.PackagingItemDTO">
|
<id property="id" column="id"/>
|
<result property="partId" column="part_id"/>
|
<result property="stockId" column="stock_id"/>
|
<result property="outBatchNo" column="out_batch_no"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="packageQty" column="package_qty"/>
|
<result property="createTime" column="create_time"/>
|
<result property="packagingId" column="packaging_id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="specs" column="specs"/>
|
<result property="locationId" column="location_id"/>
|
<result property="locationName" column="location_name"/>
|
<result property="locationNo" column="location_no"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="inLocationId" column="in_location_id"/>
|
<result property="inLocationName" column="in_location_name"/>
|
<result property="inLocationNo" column="in_location_no"/>
|
<result property="theoryWeight" column="theory_weight"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="lotTrackingIfs" column="lot_tracking_ifs"/>
|
<result property="engChgLevel" column="eng_chg_level"/>
|
</resultMap>
|
<resultMap id="packageReportMap" type="com.chinaztt.mes.warehouse.dto.PackageReportDTO">
|
<result property="createTime" column="create_time"/>
|
<result property="stepId" column="step_id"/>
|
<result property="partId" column="part_id"/>
|
<result property="staffName" column="staff_name"/>
|
<result property="stepName" column="step_name"/>
|
<result property="stepCount" column="step_count"/>
|
<result property="unit" column="unit"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
</resultMap>
|
<resultMap id="moveLibraryBoxDTOMap" type="com.chinaztt.mes.warehouse.dto.MoveLibraryBoxDTO">
|
<result property="startLocationNo" column="start_location_no"/>
|
<result property="startLocationType" column="start_location_type"/>
|
<result property="startLocationId" column="start_location_id"/>
|
<result property="arriveLocationNo" column="arrive_location_no"/>
|
<result property="arriveLocationType" column="arrive_location_type"/>
|
<result property="arriveLocationId" column="arrive_location_id"/>
|
<result property="startLocationNoIfs" column="start_location_no_ifs"/>
|
<result property="arriveLocationNoIfs" column="arrive_location_no_ifs"/>
|
<result property="moveQty" column="move_qty"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="batchNo" column="batch_no"/>
|
<result property="engChgLevel" column="eng_chg_level"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="stockId" column="stock_id"/>
|
<result property="lotTrackingIfs" column="lot_tracking_ifs"/>
|
</resultMap>
|
<select id="getPackagingItemPage" resultMap="packagingItemMapDTO">
|
SELECT A.*,bp.part_no,bp.part_name,bl.loc_name location_name,bl2.loc_name in_location_name,bl2.loc_no in_location_no
|
FROM warehouse_packaging_item A
|
LEFT JOIN basic_part bp ON bp."id" = A.part_id
|
LEFT JOIN basic_location bl ON A.location_id = bl."id"
|
LEFT JOIN basic_location bl2 ON A.in_location_id = bl2."id"
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="getPackageReport" resultMap="packageReportMap">
|
SELECT
|
to_char( wpi.create_time, 'yyyy-MM-dd' ) AS create_time,
|
'包装' AS step_name,
|
bs.staff_name,
|
"count" ( wpi."id" ) AS step_count,
|
bp.part_no,
|
bp.part_name,
|
bp.unit
|
FROM
|
warehouse_packaging_item wpi
|
LEFT JOIN warehouse_packaging wp ON wp.ID = wpi.packaging_id
|
LEFT JOIN basic_part bp ON wpi.part_id = bp."id"
|
LEFT JOIN basic_staff bs ON bs.staff_no = wp.create_user
|
<where>
|
<if test="packageReportDTO.startTime != null">
|
and to_char( wpi.create_time, 'yyyy-MM-dd' ) <![CDATA[ >= ]]> #{packageReportDTO.startTime}
|
</if>
|
<if test="packageReportDTO.endTime != null">
|
and to_char( wpi.create_time, 'yyyy-MM-dd' ) <![CDATA[ <= ]]> #{packageReportDTO.endTime}
|
</if>
|
<if test="packageReportDTO.partId != null">
|
and wpi.part_id = ${packageReportDTO.partId}
|
</if>
|
</where>
|
GROUP BY
|
to_char( wpi.create_time, 'yyyy-MM-dd' ),
|
bp.part_no,
|
bp.part_name,
|
bp.unit,
|
bs.staff_name
|
</select>
|
|
<update id="updateInLocationNoById">
|
update warehouse_packaging_item set in_location_id = #{inLocationId} where id = #{id}
|
</update>
|
|
<select id="getEnableFinishProdList" resultType="java.lang.String">
|
SELECT loc_no FROM basic_location WHERE loc_type = #{locType} AND active = 't'
|
</select>
|
|
<select id="getLocationIdByLocationNo" resultType="java.lang.Long">
|
SELECT "id" FROM basic_location WHERE loc_no = #{inLocationNo}
|
</select>
|
|
<select id="getTheoryWeightTotal" resultType="java.lang.Double">
|
SELECT SUM(COALESCE(theory_weight,0)) theory_weight FROM warehouse_packaging_item WHERE packaging_id = #{id}
|
</select>
|
|
<select id="getMoveLibraryBoxDTOListBypackagingId" resultMap="moveLibraryBoxDTOMap">
|
SELECT DISTINCT t2.*,bp.eng_chg_level,bp.lot_tracking_ifs
|
FROM
|
(
|
SELECT
|
bl_1.loc_no start_location_no,bl_1.loc_type start_location_type,bl_1.ifs_location start_location_no_ifs,
|
bl_2.loc_no arrive_location_no,bl_2.loc_type arrive_location_type,bl_2.ifs_location arrive_location_no_ifs,
|
t1.*
|
FROM
|
(
|
SELECT ws.location_id start_location_id,ws.ifs_batch_no,wpi.stock_id,
|
wpi.part_id,wpi.out_batch_no batch_no,wpi.system_no,wpi.package_qty move_qty,wpi.in_location_id arrive_location_id,bp.part_no FROM
|
(SELECT * FROM warehouse_packaging_item WHERE packaging_id = #{packagingId}) wpi
|
LEFT JOIN warehouse_stock ws ON wpi.stock_id = ws."id" --关联库存表,获取当前库存
|
LEFT JOIN basic_part bp ON wpi.part_id = bp."id" --关联零件基础表,获取零件编号
|
) t1
|
LEFT JOIN
|
basic_location bl_1 ON t1.start_location_id = bl_1."id" --关联库位基础数据表,获取库位编号、类别
|
LEFT JOIN
|
basic_location bl_2 ON t1.arrive_location_id = bl_2."id"
|
) t2
|
LEFT JOIN basic_part bp ON t2.part_id = bp."id" --关联零件基础数据表,获取零件版本号
|
</select>
|
|
<select id="getPackagingItemCountByPackagingId" resultType="java.lang.Long">
|
SELECT COUNT(*) FROM warehouse_packaging_item WHERE packaging_id = #{packagingId}
|
</select>
|
|
<select id="getPackagingItemList" resultMap="packagingItemMap">
|
SELECT wi.* FROM warehouse_packaging_item wi
|
LEFT JOIN warehouse_packaging wp on wi.packaging_id = wp.id
|
WHERE wp.no = #{packagingNo}
|
</select>
|
|
|
<select id="getIfsPackagingList" resultMap="packagingItemMapDTO">
|
SELECT wi.*,bp.part_no,bp.lot_tracking_ifs,bp.eng_chg_level,bl.loc_no as location_no FROM warehouse_packaging_item wi
|
LEFT JOIN warehouse_packaging wp on wi.packaging_id = wp.id
|
LEFT JOIN basic_part bp on wi.part_id = bp.id
|
LEFT JOIN basic_location bl on wi.location_id = bl.id
|
WHERE wp.no = #{packagingNo}
|
</select>
|
|
</mapper>
|