危化品全生命周期管理后端
kongzy
2024-09-14 ed36af4d4cc5feac72a384d85f9032fc6dc1223a
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
<?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.HzEntryRecordMapper">
    <resultMap type="com.gkhy.hazmat.system.domain.HzEntryRecord" id="HzEntryRecordResult">
        <result property="id"       column="id"       />
        <result property="warehouseId"    column="warehouse_id"    />
        <result property="num"  column="num"  />
        <result property="batchNo"  column="batch_no"  />
        <result property="state"  column="state"  />
        <result property="basicId"  column="basic_id"  />
        <result property="companyId"         column="company_id"          />
        <result property="startCode"         column="start_code"          />
        <result property="endCode"         column="end_code"          />
        <result property="codePrex"         column="code_prex"          />
        <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"          />
        <association property="warehouse" javaType="com.gkhy.hazmat.system.domain.HzWarehouse" resultMap="wareResult" />
        <association property="hazmatBasic" javaType="com.gkhy.hazmat.system.domain.HzHazmatBasic" resultMap="hazmatBasicResult" />
 
    </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="minPackage"  column="basic_min_package"  />
        <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"  />
        <result property="maxEntry"  column="max_entry"  />
    </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="selectEntryRecordVo">
        select a.id, a.warehouse_id, a.num,a.batch_no,a.state,a.basic_id,a.company_id,a.start_code,a.end_code,a.code_prex,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,b.min_package as basic_min_package,b.max_entry,
               c.id as warehouse_id,c.name as warehouse_name
        from hz_entry_record a
        left join hz_hazmat_basic b on b.id=a.basic_id
        left join hz_warehouse c on c.id=a.warehouse_id
    </sql>
    <select id="selectEntryRecordList" resultMap="HzEntryRecordResult"
            parameterType="com.gkhy.hazmat.system.domain.HzEntryRecord">
        <include refid="selectEntryRecordVo"/>
        <where>
            <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>
            <if test="companyId != null">
                AND a.company_id= #{companyId}
            </if>
            <if test="state != null">
                AND a.state= #{state}
            </if>
        </where>
        order by a.id desc
    </select>
 
    <select id="selectLastEntryRecord" resultType="com.gkhy.hazmat.system.domain.HzEntryRecord">
        select * from hz_entry_record where company_id=#{companyId} and code_prex=#{codePrex} order by id desc limit 1
    </select>
 
    <select id="entryCountStatic" resultType="com.gkhy.hazmat.system.domain.vo.HzEntryRecordVO">
        select count(*) as count,month(create_time) as month,day(create_time) as day from hz_entry_record
        where create_time &gt;= #{startTime} and create_time &lt;= #{endTime}
            <if test="companyId!=null">
            and company_id=#{companyId}
            </if>
        group by month,day
        order by month asc,day asc
    </select>
</mapper>