<?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.chinaztt.mes.warehouse.mapper.StockMapper">
|
|
<resultMap id="warehouseStockMap" type="com.chinaztt.mes.warehouse.dto.StockDTO">
|
<id property="id" column="id"/>
|
<result property="partId" column="part_id"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="locationId" column="location_id"/>
|
<result property="stockQuantity" column="stock_quantity"/>
|
<result property="reserveQuantity" column="reserve_quantity"/>
|
<result property="availableStockQuantity" column="available_stock_quantity"/>
|
<result property="sStockQuantity" column="s_stock_quantity"/>
|
<result property="sReserveQuantity" column="s_reserve_quantity"/>
|
<result property="sAvailableStockQuantity" column="s_available_stock_quantity"/>
|
<result property="factoryName" column="factory_name"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partDescription" column="part_description"/>
|
<result property="warehouseName" column="warehouse_name"/>
|
<result property="warehouseNo" column="warehouse_no"/>
|
<result property="locationName" column="loc_name"/>
|
<result property="locationNo" column="loc_no"/>
|
<result property="unit" column="unit"/>
|
<result property="sunit" column="sunit"/>
|
<result property="specs" column="specs"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="status" column="status"/>
|
<result property="warehouseId" column="warehouse_id"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="sourceName" column="name"/>
|
<result property="operationStockStatus" column="operation_stock_status"/>
|
<result property="customerOrderNo" column="customer_order_no"/>
|
<result property="mpsNo" column="mps_no"/>
|
<result property="startMetre" column="start_metre"/>
|
<result property="endMetre" column="end_metre"/>
|
<result property="outerColor" column="outer_color"/>
|
<result property="insulationColor" column="insulation_color"/>
|
<result property="locationType" column="loc_type"/>
|
<result property="moNo" column="mo_no"/>
|
<result property="cusMaterialCode" column="cus_material_code"/>
|
</resultMap>
|
|
<resultMap id="moveLibraryBoxDTOMap" type="com.chinaztt.mes.warehouse.dto.MoveLibraryBoxDTO">
|
<result property="planningMethod" column="planning_method"/>
|
<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"/>
|
</resultMap>
|
|
<resultMap id="inventoryDetailMap" type="com.chinaztt.mes.warehouse.entity.InventoryDetail">
|
<id property="id" column="id"/>
|
<result property="inventoryMainId" column="inventory_main_id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="planningMethod" column="planning_method"/>
|
<result property="sn" column="sn"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="warehouseId" column="warehouse_id"/>
|
<result property="warehouseName" column="warehouse_name"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="stockQuantity" column="stock_quantity"/>
|
<result property="unit" column="unit"/>
|
<result property="inyQty" column="iny_qty"/>
|
<result property="inyDiffQty" column="iny_diff_qty"/>
|
<result property="commitNum" column="commit_num"/>
|
<result property="createUser" column="create_user"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="inyNo" column="iny_no"/>
|
</resultMap>
|
|
|
<resultMap id="feederCertificateMap" type="com.chinaztt.mes.warehouse.dto.FeederCertificateDTO">
|
<result property="sn" column="sn"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="specs" column="specs"/>
|
<result property="partModel" column="part_model"/>
|
<result property="stockQuantity" column="stock_quantity"/>
|
<result property="date" column="date"/>
|
<result property="examiner" column="examiner"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="prodName" column="prod_name"/>
|
<result property="locationId" column="location_id"/>
|
</resultMap>
|
|
|
<resultMap id="feederManufacturingOrderMap" type="com.chinaztt.mes.warehouse.dto.FeederManufacturingOrderDTO">
|
<result property="ifsOrderNo" column="ifs_order_no"/>
|
<result property="ifsReleaseNo" column="ifs_release_no"/>
|
<result property="ifsSequenceNo" column="ifs_sequence_no"/>
|
<result property="partNo" column="part_no"/>
|
<result property="outBatchNo" column="out_batch_no"/>
|
<result property="stockQuantity" column="stock_quantity"/>
|
<result property="engChgLevel" column="eng_chg_level"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="ifsLocationArrived" column="ifs_location_arrived"/>
|
<result property="qualifiedLocation" column="qualified_location"/>
|
<result property="unqualifiedLocation" column="unqualified_location"/>
|
<result property="detectionLocation" column="detection_location"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
<result property="ifsLocation" column="ifs_location"/>
|
<result property="lotTrackingIfs" column="lot_tracking_ifs"/>
|
</resultMap>
|
|
<select id="getSumStockQuantity" resultType="java.math.BigDecimal">
|
select
|
"sum"(tempA.stock_quantity)
|
from (
|
select ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
too."name",
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.outer_color,
|
ws.insulation_color,
|
ws.start_metre,
|
ws.end_metre,
|
pmo.mo_no
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
left join production_product_output ppo on ws.system_no = ppo.system_no
|
left join production_product_main ppm on ppo.product_main_id = ppm."id"
|
left join production_operation_task pot on ppm.operation_task_id = pot."id"
|
left join plan_manufacturing_order_routing_operation pmoro on pot.mo_routing_operation_id = pmoro."id"
|
left join technology_operation too on pmoro.operation_id = too."id"
|
left join production_operation_task_supply pots on pot.id = pots.operation_task_id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
where ws.stock_quantity + ws.available_stock_quantity + ws.reserve_quantity > 0
|
order by ws.create_time asc
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
<select id="getStockPage" resultMap="warehouseStockMap">
|
select *
|
from (
|
select ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
too."name",
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.outer_color,
|
ws.insulation_color,
|
ws.start_metre,
|
ws.end_metre,
|
pmo.mo_no,
|
bcprm.cus_material_code AS cus_material_code
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
left join production_product_output ppo on ws.system_no = ppo.system_no
|
left join production_product_main ppm on ppo.product_main_id = ppm."id"
|
left join production_operation_task pot on ppm.operation_task_id = pot."id"
|
left join plan_manufacturing_order_routing_operation pmoro on pot.mo_routing_operation_id = pmoro."id"
|
left join technology_operation too on pmoro.operation_id = too."id"
|
left join production_operation_task_supply pots on pot.id = pots.operation_task_id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
LEFT JOIN basic_customer_part_relation_map bcprm ON bp.part_no = bcprm.part_no
|
where ws.stock_quantity + ws.available_stock_quantity + ws.reserve_quantity > 0
|
order by ws.create_time asc
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
<select id="getStockBySn" resultMap="warehouseStockMap">
|
select *
|
from (
|
select ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
too."name",
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.outer_color,
|
ws.insulation_color,
|
ws.start_metre,
|
ws.end_metre,
|
pmo.mo_no
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
left join production_product_output ppo on ws.system_no = ppo.system_no
|
left join production_product_main ppm on ppo.product_main_id = ppm."id"
|
left join production_operation_task pot on ppm.operation_task_id = pot."id"
|
left join plan_manufacturing_order_routing_operation pmoro on pot.mo_routing_operation_id = pmoro."id"
|
left join technology_operation too on pmoro.operation_id = too."id"
|
left join production_operation_task_supply pots on pot.id = pots.operation_task_id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
where ws.stock_quantity + ws.available_stock_quantity + ws.reserve_quantity > 0
|
order by ws.create_time asc
|
) tempA
|
where tempA.part_batch_no = #{partBatchNo}
|
</select>
|
|
<resultMap id="feedingStockMap" type="com.chinaztt.mes.warehouse.dto.FeedingStockDTO">
|
<id property="id" column="id"/>
|
<result property="partId" column="part_id"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="locationId" column="location_id"/>
|
<result property="stockQuantity" column="stock_quantity"/>
|
<result property="reserveQuantity" column="reserve_quantity"/>
|
<result property="availableStockQuantity" column="available_stock_quantity"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partDescription" column="part_description"/>
|
<result property="reelNumber" column="reel_number"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="unit" column="unit"/>
|
<result property="specs" column="specs"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="status" column="status"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="ifsBatchNo" column="ifs_batch_no"/>
|
</resultMap>
|
|
<select id="getFeedingStock" resultMap="feedingStockMap">
|
select *
|
from (
|
SELECT
|
ws.ID,
|
ws.create_time,
|
ws.update_time,
|
ws.create_user,
|
ws.update_user,
|
#{workstationId} workstation_id,
|
bp.specs,
|
bp.part_name,
|
bp.part_no,
|
bp.description part_description,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
ws.part_id,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
bl.loc_no
|
FROM
|
warehouse_stock ws
|
LEFT JOIN basic_part bp ON bp."id" = ws.part_id
|
LEFT JOIN basic_location bl ON ws.location_id = bl."id"
|
WHERE
|
ws.location_id IN (SELECT location_id FROM basic_workstation_location WHERE workstation_id = #{workstationId} AND location_type = 5) and ws.stock_quantity > 0
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="pdaList" resultType="com.alibaba.fastjson.JSONObject">
|
SELECT
|
workstation_no "workstationNo",
|
workstation_name "workstationName",
|
part_no "partNo",
|
part_name "partName",
|
part_batch_no "partBatchNo",
|
system_no "systemNo",
|
stock_quantity "suppliedQuantity",
|
create_time "createTime",
|
loc_name "locName",
|
loc_no "locNo"
|
FROM
|
(
|
SELECT
|
bw.workstation_no,
|
bw.NAME "workstation_name",
|
bp.part_no,
|
bp.part_name,
|
ws.part_batch_no,
|
ws.system_no,
|
ws.stock_quantity,
|
ws.create_time,
|
bl.loc_name,
|
bl.loc_no
|
FROM
|
warehouse_stock ws
|
LEFT JOIN basic_part bp ON bp."id" = ws.part_id
|
LEFT JOIN basic_workstation_location bwl ON bwl.location_id = ws.location_id
|
LEFT JOIN basic_workstation bw ON bw."id" = bwl.workstation_id
|
LEFT JOIN basic_location bl ON bl."id" = ws.location_id
|
WHERE
|
bwl.location_type = 5
|
AND ws.stock_quantity > 0
|
) tempa
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="getStockByPartIdPage" resultMap="warehouseStockMap">
|
select ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
WHERE bp.id = #{partId}
|
order by ws.id desc
|
</select>
|
|
<select id="getStockByWorkstationId" resultMap="warehouseStockMap">
|
select * from (
|
select ws."id",
|
bwl.workstation_id as workstation_id,
|
bp.id part_id,
|
bp.part_no,
|
bp.part_name,
|
bp.description part_description,
|
ws.part_batch_no,
|
bp.specs,
|
bp.unit,
|
ws.system_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.reel_number,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
wl.loc_name,
|
wl.loc_no,
|
ws.status,
|
ws.ifs_batch_no,
|
ws.location_id,
|
ws.operation_stock_status
|
from warehouse_stock ws
|
left join basic_part bp on bp."id" = ws.part_id
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_workstation_location bwl on bwl.location_id = wl."id"
|
where ws.available_stock_quantity > 0 and bwl.location_type = 1
|
order by wl."id",ws."id" desc)temp
|
<where>
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.sqlSegment}
|
</if>
|
</where>
|
</select>
|
|
|
|
<select id="getToDealStockByWorkstationId" resultMap="warehouseStockMap">
|
select * from (
|
select ws."id",
|
bwl.workstation_id as workstation_id,
|
bp.id part_id,
|
bp.part_no,
|
bp.part_name,
|
bp.description part_description,
|
ws.part_batch_no,
|
bp.specs,
|
bp.unit,
|
ws.system_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.reel_number,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
wl.loc_name,
|
wl.loc_no,
|
ws.status,
|
ws.ifs_batch_no
|
from warehouse_stock ws
|
left join basic_part bp on bp."id" = ws.part_id
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_workstation_location bwl on bwl.location_id = wl."id"
|
where ws.available_stock_quantity > 0 and bwl.location_type = 6
|
order by wl."id",ws."id" desc)temp
|
<where>
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.sqlSegment}
|
</if>
|
</where>
|
</select>
|
|
<select id="getStockByLocation" resultMap="warehouseStockMap">
|
select
|
bp.part_no,
|
ws.part_id
|
from warehouse_stock ws
|
left join basic_part bp on bp."id" = ws.part_id
|
<if test="ids!=null and ids.size>0">
|
where ws.location_id in
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
|
<select id="getStock" resultMap="warehouseStockMap">
|
SELECT ws.*,
|
bf.factory_name,
|
bp.part_no,
|
bp.part_name,
|
bp.description part_description,
|
ws.part_batch_no,
|
bp.specs,
|
bp.unit,
|
wl.loc_name,
|
wl.loc_no,
|
ww.warehouse_name
|
FROM warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = wl.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
WHERE ws.part_id = #{id}
|
<if test="id1 != null and id1 != ''">
|
and ws.location_id = #{id1}
|
</if>
|
<if test="ew != null and ew != ''">
|
and ws.part_batch_no = #{ew}
|
</if>
|
<if test="condition !=null">
|
and ws.available_stock_quantity ${condition}
|
</if>
|
</select>
|
|
|
<select id="countStock" resultType="java.lang.Integer">
|
SELECT count(*)
|
FROM warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = wl.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
WHERE ws.part_id = #{id}
|
<if test="id1 != null and id1 != ''">
|
and ws.location_id = #{id1}
|
</if>
|
<if test="ew != null and ew != ''">
|
and ws.part_batch_no = #{ew}
|
</if>
|
<if test="condition !=null">
|
and ws.available_stock_quantity ${condition}
|
</if>
|
</select>
|
|
<select id="getStockPageByOperation" resultMap="warehouseStockMap">
|
select *
|
from (select
|
ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
bp.unit,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
where ws.stock_quantity > 0
|
<if test="operationTaskId != null and operationTaskId != 0 ">
|
and exists(select 1 from production_operation_task_material potm
|
where potm.operation_task_id= #{operationTaskId} AND potm.part_id = ws.part_id)
|
</if>
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<!--<select id="getStockListByOperation" resultMap="warehouseStockMap">-->
|
<!--select *-->
|
<!--from (select-->
|
<!--ws.id,-->
|
<!--bf.factory_name,-->
|
<!--ws.part_no,-->
|
<!--ws.description part_description,-->
|
<!--ww.warehouse_name,-->
|
<!--ww.id warehouse_id,-->
|
<!--ww.warehouse_no,-->
|
<!--wl.loc_name,-->
|
<!--ws.part_batch_no,-->
|
<!--ws.stock_quantity,-->
|
<!--ws.reserve_quantity,-->
|
<!--ws.available_stock_quantity,-->
|
<!--ws.unit,-->
|
<!--ws.s_stock_quantity,-->
|
<!--ws.s_reserve_quantity,-->
|
<!--ws.s_available_stock_quantity,-->
|
<!--ws.reel_number,-->
|
<!--wl.loc_no,-->
|
<!--ws.part_id,-->
|
<!--ws.part_name,-->
|
<!--ws.location_id,-->
|
<!--ws.status,-->
|
<!--ws.system_no-->
|
<!--from (select w.*,b.part_no,b.description,b.unit,b.part_name-->
|
<!--from warehouse_stock w-->
|
<!--join basic_part b on w.part_id = b.id-->
|
<!--join (select part_batch_no-->
|
<!--from quality_result-->
|
<!--where (apply_type = '01output' or apply_type = '00outputfirst') and is_used = true-->
|
<!--group by part_batch_no-->
|
<!--HAVING count(system_no) = 2) q on w.part_batch_no = q.part_batch_no-->
|
<!--where b.material_type = '半成品'-->
|
<!--union all-->
|
<!--select w.*,b.part_no,b.description,b.unit,b.part_name-->
|
<!--from warehouse_stock w-->
|
<!--join basic_part b on w.part_id = b.id-->
|
<!--join quality_result q on w.system_no = q.system_no and w.part_batch_no = q.part_batch_no-->
|
<!--where b.material_type = '成品'-->
|
<!--and q.apply_type = '06finishedproduct'-->
|
<!--and q.is_used = true-->
|
<!--union all-->
|
<!--select w.*,b.part_no,b.description,b.unit,b.part_name-->
|
<!--from warehouse_stock w-->
|
<!--join basic_part b on w.part_id = b.id-->
|
<!--where b.material_type = '原材料') ws-->
|
<!--left join basic_location wl on wl."id" = ws.location_id-->
|
<!--left join basic_warehouse ww on ww."id" = wl.loc_group-->
|
<!--left join basic_factory bf on bf."id" = ww.factory_id-->
|
<!--where ws.stock_quantity > 0-->
|
<!--<if test="operationTaskId != null and operationTaskId != 0 ">-->
|
<!--and exists(select 1 from production_operation_task_material potm-->
|
<!--where potm.operation_task_id= #{operationTaskId} AND potm.part_id = ws.part_id)-->
|
<!--</if>-->
|
<!--) tempA-->
|
<!--<if test="ew.emptyOfWhere == false">-->
|
<!--${ew.customSqlSegment}-->
|
<!--</if>-->
|
<!--</select>-->
|
|
<select id="getStockListByOperation" resultMap="warehouseStockMap">
|
select *
|
from (
|
select
|
ws.id,
|
bf.factory_name,
|
ws.part_no,
|
ws.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.unit,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
ws.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.sunit
|
from (SELECT
|
w.*,
|
bp.part_no,
|
bp.description,
|
bp.unit,
|
bp.part_name,
|
bp.sunit
|
FROM
|
warehouse_stock w
|
LEFT JOIN basic_part bp ON w.part_id = bp."id"
|
WHERE
|
bp.material_type = '1'
|
AND bp.planning_method = 'A') ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
where ws.stock_quantity > 0
|
<if test="operationTaskId != null and operationTaskId != 0 ">
|
and exists(select 1 from production_operation_task_material potm where potm.operation_task_id= #{operationTaskId} AND potm.part_id = ws.part_id)
|
</if>
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
|
<select id="getSerialNoBySystemNo" resultType="java.lang.String">
|
SELECT pmo.ifs_sequence_no
|
FROM (SELECT * FROM production_product_output WHERE system_no = #{systemNo}) ppo
|
LEFT JOIN production_product_main ppm ON ppo.product_main_id = ppm."id"
|
LEFT JOIN production_operation_task pot ON ppm.operation_task_id = pot."id"
|
LEFT JOIN production_operation_task_supply pots ON pot."id" = pots.operation_task_id
|
LEFT JOIN plan_manufacturing_order pmo ON pots.mo_id = pmo."id"
|
</select>
|
|
<select id="getEnableStockObjList" resultMap="warehouseStockMap">
|
SELECT
|
ws.*,
|
bl.loc_no,
|
bp.unit,
|
bp.part_name,
|
bp.part_no
|
FROM
|
(SELECT * FROM warehouse_stock WHERE part_batch_no = #{sn} and available_stock_quantity > 0) ws
|
LEFT JOIN basic_location bl ON ws.location_id = bl."id"
|
LEFT JOIN basic_part bp ON ws.part_id = bp."id"
|
</select>
|
|
<select id="getEnableLocationObjList" resultType="com.alibaba.fastjson.JSONObject">
|
SELECT DISTINCT
|
bl.loc_no "locNo",
|
bl.loc_name "locName",
|
bl.loc_type "locType",
|
bl.loc_status "locStatus",
|
sdi.label "locTypeName",
|
CASE
|
WHEN bl.loc_status = 1 THEN '使用'
|
WHEN bl.loc_status = 0 THEN '停产'
|
ELSE '状态未识别' END "locStatusName"
|
FROM (SELECT loc_no,loc_name,loc_type,loc_status FROM basic_location WHERE loc_status = 1 AND active = 't') bl --库位状态使用的是约定,并没有在数据字典中维护
|
LEFT JOIN (SELECT * FROM sys_dict_item WHERE dict_id = 37) sdi ON bl.loc_type = sdi."value" --锁定仓库类型数据字典id
|
</select>
|
|
<select id="getMoveLibraryBoxDTOListByStockId" resultMap="moveLibraryBoxDTOMap">
|
SELECT DISTINCT bl_1.loc_no start_location_no,bl_1.loc_type start_location_type,bl_1.ifs_location start_location_no_ifs,t1.*
|
FROM
|
(SELECT ws.location_id start_location_id,ws.part_id,ws.part_batch_no batch_no,ws.system_no,ws.ifs_batch_no,bp.part_no,bp.eng_chg_level,bp.planning_method
|
FROM (SELECT * FROM warehouse_stock WHERE "id" = #{stockId}) ws
|
LEFT JOIN basic_part bp ON ws.part_id = bp."id" --关联零件基础表,获取零件编号
|
) t1
|
LEFT JOIN basic_location bl_1 ON t1.start_location_id = bl_1."id" --关联库位基础数据表,获取库位编号、类别、对应的ifs库位编号
|
</select>
|
<select id="getStockMoNo" resultType="java.lang.String">
|
select distinct pmo.mo_no
|
from warehouse_stock ws
|
left join production_product_output ppo on ws.part_batch_no = ppo.out_batch_no
|
left join production_product_main ppm on ppo.product_main_id = ppm.id
|
left join production_operation_task pot
|
on ppm.operation_task_id = pot.id
|
left join production_operation_task_supply pots on pots.operation_task_id = pot.id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
where ws.id = #{id};
|
</select>
|
<select id="getStockOperationStatus" resultType="java.lang.Boolean">
|
select distinct operation_stock_status
|
from warehouse_stock
|
where part_batch_no = #{outBatchNo}
|
and part_id = #{partId}
|
and system_no = #{systemNo}
|
</select>
|
|
|
<select id="getStockByInventory" resultMap="inventoryDetailMap">
|
select
|
bp.part_no,
|
bp.part_name,
|
bp.planning_method,
|
ws.part_batch_no as sn,
|
ws.ifs_batch_no,
|
bw.id as warehouse_id,
|
bw.warehouse_name,
|
bl.loc_no,
|
ws.stock_quantity,
|
bp.unit
|
from warehouse_stock as ws
|
left join basic_location as bl on ws.location_id = bl."id"
|
left join basic_warehouse as bw on bl.loc_group = bw."id"
|
left join basic_part as bp on ws.part_id = bp."id"
|
<where>
|
ws.stock_quantity > 0
|
<if test="locationIds!=null and locationIds.size>0">
|
and ws.location_id in
|
<foreach item="item" index="index" collection="locationIds" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="warehouseIds!=null and warehouseIds.size>0">
|
and bl.loc_group in
|
<foreach item="item" index="index" collection="warehouseIds" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="partId != null">
|
and ws.part_id = #{partId}
|
</if>
|
</where>
|
</select>
|
<select id="getFinishProductStock" resultMap="warehouseStockMap">
|
select ws.*,bp.part_name,bl.loc_no,bp.part_no,bp.unit,bl.loc_type
|
from warehouse_stock ws
|
left join basic_location bl on ws.location_id = bl.id
|
left join basic_part bp on ws.part_id = bp.id
|
where ws.part_batch_no = #{sn}
|
and bp.part_no = #{partNo}
|
-- and bl.loc_type = '2'
|
and ws.available_stock_quantity > 0;
|
</select>
|
|
|
<select id="getStockByLocIdAndSn" resultMap="inventoryDetailMap">
|
select
|
bp.part_no,
|
bp.part_name,
|
ws.part_batch_no as sn,
|
ws.ifs_batch_no,
|
bp.unit,
|
ws.stock_quantity as iny_qty
|
from warehouse_stock as ws
|
left join basic_part as bp on ws.part_id = bp."id"
|
<where>
|
<if test="locationId != null">
|
and ws.location_id = #{locationId}
|
</if>
|
<if test="sn != null and sn!=''">
|
and ws.part_batch_no = #{sn}
|
</if>
|
</where>
|
order by ws.stock_quantity desc
|
</select>
|
|
|
|
<select id="getStockPageByLocNo" resultMap="warehouseStockMap">
|
select *
|
from (
|
select ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
too."name",
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.outer_color,
|
ws.insulation_color,
|
ws.start_metre,
|
ws.end_metre
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
left join production_product_output ppo on ws.system_no = ppo.system_no
|
left join production_product_main ppm on ppo.product_main_id = ppm."id"
|
left join production_operation_task pot on ppm.operation_task_id = pot."id"
|
left join plan_manufacturing_order_routing_operation pmoro on pot.mo_routing_operation_id = pmoro."id"
|
left join technology_operation too on pmoro.operation_id = too."id"
|
where ws.stock_quantity + ws.available_stock_quantity + ws.reserve_quantity > 0
|
and wl.loc_no like '%001'
|
order by ws.create_time asc
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
<select id="getFinishLocationProduct" resultType="java.lang.Integer">
|
select count(ws.id)
|
from warehouse_stock ws
|
left join basic_location bl on ws.location_id = bl.id
|
where ws.part_batch_no = #{partBatchNo}
|
and ws.part_id = #{partId}
|
and bl.loc_type = '8'
|
and ws.stock_quantity > 0
|
</select>
|
|
|
|
<select id="getFeederCertificate" resultMap="feederCertificateMap">
|
select
|
bp.part_no,
|
ws.part_batch_no as sn,
|
ws.stock_quantity,
|
ws.ifs_batch_no,
|
bp.part_name,
|
bp.specs,
|
bp.part_model,
|
bp.examiner,
|
bp.prod_name,
|
ws.location_id
|
from warehouse_stock ws
|
left join basic_part bp on ws.part_id = bp.id
|
where ws.part_batch_no = #{sn}
|
and ws.available_stock_quantity > 0
|
and ws.location_id in
|
<foreach item="item" index="index" collection="locationIdList" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
|
</select>
|
|
|
<select id="getFeederManufacturingOrder" resultMap="feederManufacturingOrderMap">
|
SELECT pmo.ifs_order_no,pmo.ifs_release_no,pmo.ifs_sequence_no,bp.part_no,bp.lot_tracking_ifs,ws.ifs_batch_no,ppo.out_batch_no,ws.stock_quantity,bp.eng_chg_level,pot.workstation_id,bl.ifs_location FROM
|
(SELECT * FROM warehouse_stock WHERE part_batch_no in
|
<foreach collection="snList" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
) ws
|
LEFT JOIN
|
production_product_output ppo ON ws.system_no = ppo.system_no
|
LEFT JOIN
|
production_product_main ppm ON ppo.product_main_id = ppm."id"
|
LEFT JOIN
|
production_operation_task pot ON ppm.operation_task_id = pot.id
|
LEFT JOIN
|
production_operation_task_supply pots ON pot."id" = pots.operation_task_id
|
LEFT JOIN
|
plan_manufacturing_order pmo ON pots.mo_id = pmo."id"
|
LEFT JOIN
|
basic_part bp ON ws.part_id = bp."id"
|
LEFT JOIN
|
basic_location bl ON ws.location_id = bl."id"
|
|
</select>
|
|
|
|
<select id="getProductionByInventory" resultMap="inventoryDetailMap">
|
select
|
bp.part_no,
|
bp.part_name,
|
bp.planning_method,
|
ppi.part_batch_no as sn,
|
ppi.ifs_batch_no,
|
bw.id as warehouse_id,
|
bw.warehouse_name,
|
bl.loc_no,
|
ppi.input_quantity as stock_quantity,
|
bp.unit
|
from production_product_main ppm
|
left join production_product_input ppi on ppm.id = ppi.product_main_id
|
left join warehouse_stock ws on ws.id = ppi.stock_id
|
left join basic_location as bl on ws.location_id = bl."id"
|
left join basic_warehouse as bw on bl.loc_group = bw."id"
|
left join basic_part as bp on ppi.part_id = bp."id"
|
<where>
|
ppm.state in ('01draft','04processing')
|
<if test="locationIds!=null and locationIds.size>0">
|
and ws.location_id in
|
<foreach item="item" index="index" collection="locationIds" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="warehouseIds!=null and warehouseIds.size>0">
|
and bl.loc_group in
|
<foreach item="item" index="index" collection="warehouseIds" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="partId != null">
|
and ppi.part_id = #{partId}
|
</if>
|
</where>
|
</select>
|
|
|
|
<select id="getStockBySnList" resultMap="warehouseStockMap">
|
select
|
ws.id,
|
bf.factory_name,
|
bp.part_no,
|
bp.description part_description,
|
ww.warehouse_name,
|
ww.id warehouse_id,
|
ww.warehouse_no,
|
wl.loc_name,
|
ws.part_batch_no,
|
ws.stock_quantity,
|
ws.reserve_quantity,
|
ws.available_stock_quantity,
|
ws.s_stock_quantity,
|
ws.s_reserve_quantity,
|
ws.s_available_stock_quantity,
|
ws.operation_stock_status,
|
bp.sunit,
|
bp.unit,
|
ws.reel_number,
|
wl.loc_no,
|
ws.part_id,
|
bp.part_name,
|
ws.location_id,
|
ws.status,
|
ws.system_no,
|
ws.ifs_batch_no,
|
too."name",
|
ws.customer_order_no,
|
ws.mps_no,
|
ws.outer_color,
|
ws.insulation_color,
|
ws.start_metre,
|
ws.end_metre,
|
pmo.mo_no
|
from warehouse_stock ws
|
left join basic_location wl on wl."id" = ws.location_id
|
left join basic_warehouse ww on ww."id" = wl.loc_group
|
left join basic_factory bf on bf."id" = ww.factory_id
|
left join basic_part bp on bp."id" = ws.part_id
|
left join production_product_output ppo on ws.system_no = ppo.system_no
|
left join production_product_main ppm on ppo.product_main_id = ppm."id"
|
left join production_operation_task pot on ppm.operation_task_id = pot."id"
|
left join plan_manufacturing_order_routing_operation pmoro on pot.mo_routing_operation_id = pmoro."id"
|
left join technology_operation too on pmoro.operation_id = too."id"
|
left join production_operation_task_supply pots on pot.id = pots.operation_task_id
|
left join plan_manufacturing_order pmo on pmo.id = pots.mo_id
|
where ws.stock_quantity + ws.available_stock_quantity + ws.reserve_quantity > 0
|
and ws.part_batch_no in
|
<foreach collection="snList" item="sn" separator="," open="(" close=")">
|
#{sn}
|
</foreach>
|
order by ws.create_time asc
|
</select>
|
|
</mapper>
|