<?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.CheckDetailMapper">
|
|
<resultMap id="checkDetailMap" type="com.chinaztt.mes.warehouse.dto.CheckDetailDTO">
|
<id property="id" column="id"/>
|
<result property="warehouseCheckId" column="warehouse_check_id"/>
|
<result property="partId" column="part_id"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="locationId" column="location_id"/>
|
<result property="locQty" column="loc_qty"/>
|
<result property="unit" column="unit"/>
|
<result property="chkQty" column="chk_qty"/>
|
<result property="chkDiffQty" column="chk_diff_qty"/>
|
<result property="partNo" column="part_no"/>
|
<result property="locName" column="loc_name"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="status" column="status"/>
|
<result property="systemNo" column="system_no"/>
|
<result property="adjQty" column="adj_qty"/>
|
<result property="adjReason" column="adj_reason"/>
|
</resultMap>
|
<select id="getCheckDetail" resultMap="checkDetailMap">
|
INSERT INTO warehouse_check_detail(location_id,part_id,part_batch_no,loc_qty,unit,warehouse_check_id,status,system_no)
|
SELECT
|
ws.location_id,ws.part_id,ws.part_batch_no,ws.stock_quantity,bp.unit,#{ew.id} as warehouse_check_id,'待盘' as
|
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
|
bf."id"=#{ew.factoryId}
|
<if test="ew.warehouseId!=null and ew.warehouseId!=''">
|
and ww."id"=#{ew.warehouseId}
|
</if>
|
<if test="ew.locationIds!=null and ew.locationIds.size>0">
|
AND EXISTS(select 1 from warehouse_check_location wcl where wcl.location_id=wl."id" and
|
wcl.check_main_id=#{ew.id})
|
</if>
|
<if test="ew.partIds!=null and ew.partIds.size>0">
|
AND EXISTS (select 1 from warehouse_check_part wcp where wcp.part_id=ws.part_id and
|
wcp.check_main_id=#{ew.id})
|
</if>
|
</select>
|
<select id="getCheckDetailPage" resultMap="checkDetailMap">
|
SELECT
|
a.chk_diff_qty,a.chk_qty,a."id",a.loc_qty,a.part_batch_no,a.unit,a.warehouse_check_id,b.part_no,c.loc_name,a.status,c.loc_no
|
FROM warehouse_check_detail a
|
LEFT JOIN basic_part b ON b."id" = a.part_id
|
LEFT JOIN basic_location c ON c."id" = a.location_id
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
<select id="getCheckDetailById" resultMap="checkDetailMap">
|
SELECT
|
a.chk_diff_qty,a.chk_qty,a."id",a.loc_qty,a.part_batch_no,a.unit,a.warehouse_check_id,b.part_no,c.loc_name,a.status
|
FROM warehouse_check_detail a
|
LEFT JOIN basic_part b ON b."id" = a.part_id
|
LEFT JOIN basic_location c ON c."id" = a.location_id
|
where a."id" = #{id}
|
</select>
|
<select id="findCheckDetailByNo" resultMap="checkDetailMap">
|
SELECT
|
A.chk_diff_qty,
|
A.chk_qty,
|
A.status,
|
A."id",
|
A.loc_qty,
|
A.location_id,
|
A.part_batch_no,
|
A.part_id,
|
A.unit,
|
A.warehouse_check_id,
|
b.part_no,
|
C.loc_name,
|
C.loc_no
|
FROM
|
warehouse_check_main e
|
LEFT JOIN warehouse_check_detail A ON A.warehouse_check_id = e."id"
|
LEFT JOIN basic_part b ON b."id" = A.part_id
|
LEFT JOIN basic_location C ON C."id" = A.location_id
|
where e.chk_no = #{ew.chkNo}
|
</select>
|
<select id="getCheckDetailByNo" resultMap="checkDetailMap">
|
SELECT
|
A.*
|
FROM
|
warehouse_check_main e
|
LEFT JOIN warehouse_check_detail A ON A.warehouse_check_id = e."id"
|
LEFT JOIN basic_part b ON b."id" = A.part_id
|
LEFT JOIN basic_location C ON C."id" = A.location_id
|
where e.chk_no = #{ew.chkNo}
|
and b.part_no =#{ew.partNo}
|
and C.loc_no = #{ew.locNo}
|
and A.part_batch_no = #{ew.partBatchNo}
|
</select>
|
<select id="getCheckDetailByPage" resultMap="checkDetailMap">
|
SELECT
|
a.chk_diff_qty,a.chk_qty,a."id",a.loc_qty,a.part_batch_no,a.unit,a.warehouse_check_id,b.part_no,c.loc_name,a.status,d.adj_qty,d.adj_reason,c.loc_no
|
FROM warehouse_check_detail a
|
LEFT JOIN basic_part b ON b."id" = a.part_id
|
LEFT JOIN basic_location c ON c."id" = a.location_id
|
LEFT JOIN warehouse_check_diffadj_detail d on d.check_detail_id = a."id"
|
WHERE a.status in ('盘盈','盘亏')
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
</mapper>
|