<?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.CheckMainMapper">
|
|
<resultMap id="checkMainMap" type="com.chinaztt.mes.warehouse.dto.CheckMainDTO">
|
<id property="id" column="id"/>
|
<result property="chkNo" column="chk_no"/>
|
<result property="factoryId" column="factory_id"/>
|
<result property="warehouseId" column="warehouse_id"/>
|
<result property="chkType" column="chk_type"/>
|
<result property="chkDesc" column="chk_desc"/>
|
<result property="chkStatus" column="chk_status"/>
|
<result property="factoryName" column="factory_name"/>
|
<result property="warehouseName" column="warehouse_name"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="partNo" column="part_no"/>
|
</resultMap>
|
<resultMap id="checkMainMaps" type="com.chinaztt.mes.warehouse.dto.CheckMainDTO">
|
<id property="id" column="id"/>
|
<result property="chkNo" column="chk_no"/>
|
<result property="factoryId" column="factory_id"/>
|
<result property="warehouseId" column="warehouse_id"/>
|
<result property="chkType" column="chk_type"/>
|
<result property="chkDesc" column="chk_desc"/>
|
<result property="chkStatus" column="chk_status"/>
|
<collection property="locationIds" ofType="long">
|
<id column="location_id"/>
|
</collection>
|
<collection property="partIds" ofType="long">
|
<id column="part_id"/>
|
</collection>
|
</resultMap>
|
<delete id="deleteCheckMainById">
|
DELETE FROM warehouse_check_main a WHERE a."id" = #{id};
|
DELETE FROM warehouse_check_part b WHERE b.check_main_id =#{id};
|
DELETE FROM warehouse_check_location c WHERE c.check_main_id = #{id};
|
DELETE FROM warehouse_check_detail d WHERE d.warehouse_check_id =#{id}
|
</delete>
|
<delete id="deleteCheckMain">
|
DELETE FROM warehouse_check_part b WHERE b.check_main_id =#{id};
|
DELETE FROM warehouse_check_location c WHERE c.check_main_id = #{id};
|
DELETE FROM warehouse_check_detail d WHERE d.warehouse_check_id =#{id}
|
</delete>
|
<select id="getCheckMainPage" resultMap="checkMainMap">
|
select wcm.*,(
|
select string_agg(wl.loc_no , ',') from warehouse_check_location wcl
|
left join basic_location wl on wl."id"=wcl.location_id
|
where wcl.check_main_id=wcm."id"
|
) loc_no,(
|
select string_agg(bp.part_no , ',') from warehouse_check_part wcp
|
left join basic_part bp on bp."id"=wcp.part_id
|
where wcp.check_main_id=wcm."id"
|
) part_no,D.factory_name,E.warehouse_name
|
from warehouse_check_main wcm
|
LEFT JOIN basic_factory D ON D."id" = wcm.factory_id
|
LEFT JOIN basic_warehouse E ON E."id" = wcm.warehouse_id
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.sqlSegment}
|
</if>
|
</select>
|
<select id="getCheckMainPageById" resultMap="checkMainMaps">
|
SELECT
|
A."id",A.warehouse_id,A.chk_desc,A.chk_no,A.chk_type,A.factory_id,B.part_id,C.location_id,A.chk_status
|
FROM warehouse_check_main A
|
LEFT JOIN warehouse_check_part B ON B.check_main_id = A."id"
|
LEFT JOIN warehouse_check_location C ON C.check_main_id = A."id"
|
where A."id" = #{id}
|
</select>
|
<select id="getCheckMainPdaPage" resultMap="checkMainMap">
|
SELECT
|
A."id",A.warehouse_id,A.chk_desc,A.chk_no,A.chk_type,A.factory_id,
|
A.create_time,A.update_time
|
FROM warehouse_check_main A
|
LEFT JOIN warehouse_check_part B ON B.check_main_id = A."id"
|
LEFT JOIN warehouse_check_location C ON C.check_main_id = A."id"
|
LEFT JOIN basic_factory D ON D."id" = A.factory_id
|
LEFT JOIN basic_warehouse E ON E."id" = A.warehouse_id
|
LEFT JOIN warehouse_check_detail F on F.warehouse_check_id = A."id"
|
<where>
|
A.chk_status = '已下发' and F.status = '待盘'
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
GROUP BY A."id"
|
</where>
|
|
</select>
|
<select id="getCheckPage" resultMap="checkMainMap">
|
select wcm.*,(
|
select string_agg(wl.loc_no , ',') from warehouse_check_location wcl
|
left join basic_location wl on wl."id"=wcl.location_id
|
where wcl.check_main_id=wcm."id"
|
) loc_no,(
|
select string_agg(bp.part_no , ',') from warehouse_check_part wcp
|
left join basic_part bp on bp."id"=wcp.part_id
|
where wcp.check_main_id=wcm."id"
|
) part_no,D.factory_name,E.warehouse_name
|
from warehouse_check_main wcm
|
LEFT JOIN basic_factory D ON D."id" = wcm.factory_id
|
LEFT JOIN basic_warehouse E ON E."id" = wcm.warehouse_id
|
<where> wcm.chk_status='盘点中'
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</where>
|
</select>
|
</mapper>
|