李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?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>