危化品全生命周期管理后端
kongzy
2024-08-22 0c73654f55844e34772732914af8cc1e247aab63
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
<?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.HzProductFlowMapper">
    <resultMap type="com.gkhy.hazmat.system.domain.HzProductFlow" id="HzProductFlowResult">
        <result property="id"       column="id"       />
        <result property="productId"    column="product_id"    />
        <result property="basicId"    column="basic_id"    />
        <result property="state"     column="state"     />
        <result property="num"  column="num"  />
        <result property="companyId"         column="company_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="code"         column="code"          />
        <association property="productBasic" javaType="com.gkhy.hazmat.system.domain.HzProductBasic" resultMap="productBasicResult" />
        <association property="user" javaType="com.gkhy.hazmat.common.domain.entity.SysUser" resultMap="userResult" />
 
    </resultMap>
 
    <resultMap type="com.gkhy.hazmat.system.domain.HzProductBasic" id="productBasicResult">
        <result property="id"       column="basic_id"       />
        <result property="name"    column="basic_name"    />
        <result property="cas"     column="basic_cas"     />
        <result property="minPackage"     column="basic_min_package"     />
        <result property="productType"  column="basic_product_type"  />
        <result property="productCharacter"  column="basic_product_character"  />
        <result property="supplier"  column="basic_supplier"  />
        <result property="manufacturer"  column="basic_manufacturer"  />
        <result property="metering"  column="basic_metering"  />
        <result property="unit"  column="basic_unit"  />
        <result property="productSn"  column="product_sn"  />
    </resultMap>
 
    <resultMap type="com.gkhy.hazmat.common.domain.entity.SysUser" id="userResult">
        <result property="id"       column="user_id"       />
        <result property="name"    column="user_name"    />
        <result property="departName"    column="user_depart_name"    />
    </resultMap>
 
    <sql id="selectProductFlowVo">
        select a.id, a.product_id,a.basic_id, a.state,a.num,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
       b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.product_type as basic_product_type,b.product_character as basic_product_character,
       b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,c.code,
       d.id as user_id,d.name as user_name,e.name as user_depart_name
        from hz_product_flow a
         left join hz_product_basic b on b.id=a.basic_id
         left join hz_product c on c.id=a.product_id
         left join sys_user d on d.id=a.create_id
         left join sys_dept e on e.id=d.depart_id
    </sql>
    <select id="selectProductFlowList" resultMap="HzProductFlowResult"
            parameterType="com.gkhy.hazmat.system.domain.HzProductFlow">
        <include refid="selectProductFlowVo"/>
        <where>
            <if test="companyId != null">
                AND a.company_id= #{companyId}
            </if>
            <if test="params.name != null and params.name != ''">
                AND b.name like concat(#{params.name},'%')
            </if>
            <if test="params.productSn != null and params.productSn != ''">
                AND b.product_sn like concat(#{params.productSn},'%')
            </if>
        </where>
        order by a.id desc
    </select>
 
    <select id="selectAllProductFlowByProductId" resultMap="HzProductFlowResult"
            parameterType="java.lang.Long">
        <include refid="selectProductFlowVo"/>
        where product_id=#{productId}
        order by a.id desc
    </select>
 
    <select id="selectAllProductFlowByUser" resultMap="HzProductFlowResult"
            parameterType="com.gkhy.hazmat.system.domain.HzProductFlow">
        <include refid="selectProductFlowVo"/>
        where a.create_id=#{createId} and a.company_id=#{companyId}
        order by a.id desc
    </select>
</mapper>