shiyunteng
7 天以前 0ad13cb4bf387d4f2db2d62540ebb73a376087f5
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
<?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.by4cloud.platformx.device.mapper.ReceivingNoteItemMapper">
 
  <resultMap id="receivingNoteItemMap" type="com.by4cloud.platformx.device.entity.ReceivingNoteItem">
        <id property="id" column="id"/>
        <result property="compId" column="comp_id"/>
        <result property="noteId" column="note_id"/>
        <result property="contractItemId" column="contract_item_id"/>
        <result property="num" column="num"/>
        <result property="output" column="output"/>
        <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="delFlag" column="del_flag"/>
  </resultMap>
    <select id="pageNew" resultType="com.by4cloud.platformx.device.entity.vo.ReceivingNoteItemPageVo">
        select
            rni.id,
            rni.num  ,
            rni.device_code,
            rni.device_name ,
            rni.device_models ,
            rni.key_parameter ,
            rni.metering_unit ,
            rni.`output` ,
            rn.release_code
        from
            receiving_note_item rni
        join receiving_note rn on rn.id = rni.note_id
        where
            rni.del_flag = '0'
        <if test="queryDTO.releaseCode != null and queryDTO.releaseCode !=''">
            and rn.release_code like CONCAT('%', #{queryDTO.releaseCode}, '%')
        </if>
        <if test="queryDTO.noteId != null and queryDTO.noteId !=''">
            and rni.note_id = #{queryDTO.noteId}
        </if>
    </select>
    <select id="selectDeviceNumByContractId" resultType="java.lang.Integer">
        select
            ifnull(sum(rni.num),0)
        from
            receiving_note_item rni
        where
            rni.device_id = #{deviceId}
          and exists (
                select
                    *
                from
                    receiving_note rn
                where
                    rn.contract_id = #{contractId}
                  and rn.id = rni.note_id)
    </select>
</mapper>