危化品全生命周期管理后端
heheng
2025-03-06 8b1d6e1b442c1909bd747805bd1845b40caabe0c
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
<?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.gkhy.hazmat.system.mapper.HzProductWarehouseRecordMapper">
    <resultMap type="com.gkhy.hazmat.system.domain.HzProductWarehouseRecord" id="HzWarehouseRecordResult">
        <result property="id"       column="id"       />
        <result property="basicId"    column="basic_id"    />
        <result property="warehouseId"     column="warehouse_id"     />
        <result property="remaining"  column="remaining"  />
        <result property="num"  column="num"  />
        <result property="state"  column="state"  />
        <result property="companyId"         column="company_id"          />
        <result property="createId"         column="create_id"          />
        <result property="version"         column="version"          />
        <result property="createBy"       column="create_by"       />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
        <result property="createName"         column="create_name"          />
        <association property="productBasic" javaType="com.gkhy.hazmat.system.domain.HzProductBasic" resultMap="productBasicResult" />
        <association property="warehouse" javaType="com.gkhy.hazmat.system.domain.HzWarehouse" resultMap="wareResult" />
    </resultMap>
 
 
    <resultMap id="productBasicResult" type="com.gkhy.hazmat.system.domain.HzProductBasic">
        <id     property="id"       column="product_id"        />
        <result property="name"     column="product_name"      />
        <result property="cas"     column="product_cas"      />
        <result property="productType"     column="product_type"      />
        <result property="productCharacter"     column="product_character"      />
        <result property="supplier"     column="product_supplier"      />
        <result property="manufacturer"     column="product_manufacturer"      />
        <result property="productFormat"     column="product_format"      />
        <result property="metering"     column="product_metering"      />
        <result property="unit"     column="product_unit"      />
        <result property="productSn"     column="product_product_sn"      />
    </resultMap>
 
    <resultMap id="wareResult" type="com.gkhy.hazmat.system.domain.HzWarehouse">
        <id     property="id"       column="warehouse_id"        />
        <result property="name"     column="warehouse_name"      />
    </resultMap>
 
    <sql id="selectWarehouseRecordVo">
        select a.id, a.basic_id, a.warehouse_id,a.remaining,a.num,a.state,a.company_id,a.create_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
               b.id as product_id,b.name as product_name,b.cas as product_cas,b.product_type ,b.product_character,b.supplier as product_supplier,b.manufacturer as product_manufacturer,
               b.product_format,b.metering as product_metering,b.unit as product_unit,b.product_sn as product_product_sn,
               c.id as warehouse_id,c.name as warehouse_name,d.name as create_name
        from hz_product_warehouse_record a
         left join hz_product_basic b on b.id=a.basic_id
         left join hz_warehouse c on c.id=a.warehouse_id
         left join sys_user d on d.id =a.create_id
    </sql>
 
    <select id="selectWarehouseRecordList" resultMap="HzWarehouseRecordResult"
            parameterType="com.gkhy.hazmat.system.domain.HzProductWarehouseRecord">
        <include refid="selectWarehouseRecordVo"/>
        <where>
            <if test="basicId != null and basicId != ''">
                AND a.basic_id=#{basicId}
            </if>
            <if test="warehouseId != null and warehouseId != ''">
                AND a.warehouse_id=#{warehouseId}
            </if>
            <if test="companyId != null">
                AND a.company_id =#{companyId}
            </if>
        </where>
        order by a.id desc
    </select>
</mapper>