危化品全生命周期管理后端
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?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.HzHazmatFlowMapper">
 
    <resultMap type="com.gkhy.hazmat.system.domain.HzHazmatFlow" id="HzHazmatFlowResult">
        <result property="id"       column="id"       />
        <result property="hazmatId"    column="hazmat_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="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="code"         column="code"          />
        <association property="hazmatBasic" javaType="com.gkhy.hazmat.system.domain.HzHazmatBasic" resultMap="hazmatBasicResult" />
        <association property="user" javaType="com.gkhy.hazmat.common.domain.entity.SysUser" resultMap="userResult" />
    </resultMap>
 
    <resultMap type="com.gkhy.hazmat.system.domain.HzHazmatBasic" id="hazmatBasicResult">
        <result property="id"       column="basic_id"       />
        <result property="name"    column="basic_name"    />
        <result property="cas"     column="basic_cas"     />
        <result property="hazmatType"  column="basic_hazmat_type"  />
        <result property="hazmatCharacter"  column="basic_hazmat_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="selectHazmatFlowVo">
        select a.id, a.hazmat_id,a.basic_id,a.state,a.num,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 basic_id,b.name as basic_name,b.cas as basic_cas,b.hazmat_type as basic_hazmat_type,b.hazmat_character as basic_hazmat_character,
           b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,c.code,
           d.id as user_id,d.name as user_name,e.name as user_depart_name
        from hz_hazmat_flow a
        left join hz_hazmat_basic b on b.id=a.basic_id
        left join hz_hazmat c on c.id =a.hazmat_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="selectHazmatFlowList" resultMap="HzHazmatFlowResult"
            parameterType="com.gkhy.hazmat.system.domain.HzHazmatFlow">
        <include refid="selectHazmatFlowVo"/>
        <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="selectHazmatFlowById" resultMap="HzHazmatFlowResult"
            parameterType="com.gkhy.hazmat.system.domain.HzHazmatFlow">
       <include refid="selectHazmatFlowVo"/>
        where id=#{flowId}
    </select>
 
    <select id="selectAllHazmatFlowByHazmatId" resultMap="HzHazmatFlowResult"
            parameterType="java.lang.Long">
        <include refid="selectHazmatFlowVo"/>
        where hazmat_id=#{hazmatId}
        order by a.id desc
    </select>
 
    <select id="selectAllHazmatFlowByUser" resultMap="HzHazmatFlowResult"
            parameterType="com.gkhy.hazmat.system.domain.HzHazmatFlow">
        <include refid="selectHazmatFlowVo"/>
        where a.create_id=#{createId} and a.company_id=#{companyId}
        order by a.id desc
    </select>
 
    <select id="selectLastFlow" resultType="com.gkhy.hazmat.system.domain.HzHazmatFlow"
            parameterType="java.lang.Long">
        select * from hz_hazmat_flow_#{slice} where hazmat_id=#{hazmatId}
         <if test="state!=null">
             and state=1
         </if>
         order by id desc limit 1
    </select>
 
 
</mapper>