shiyunteng
2 天以前 c6db287f6c987060d615fd7ef5126511e051d5c6
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
<?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.DeviceStocktakingRecordMapper">
 
  <resultMap id="deviceStocktakingRecordMap" type="com.by4cloud.platformx.device.entity.DeviceStocktakingRecord">
        <id property="id" column="id"/>
        <result property="compId" column="comp_id"/>
        <result property="classId" column="class_id"/>
        <result property="deviceClassId" column="device_class_id"/>
        <result property="deviceCode" column="device_code"/>
        <result property="deviceId" column="device_id"/>
        <result property="deviceModels" column="device_models"/>
        <result property="deviceName" column="device_name"/>
        <result property="planId" column="plan_id"/>
        <result property="position" column="position"/>
        <result property="recordPic" column="record_pic"/>
        <result property="recordTime" column="record_time"/>
        <result property="serialNo" column="serial_no"/>
        <result property="stocktakingUserId" column="stocktaking_user_id"/>
        <result property="abnormalMarking" column="abnormal_marking"/>
        <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="selectStocktatingResultByPlanId"
            resultType="com.by4cloud.platformx.device.entity.vo.StocktatingRecordVo">
        select
            d.class_id ,
            dc.name className,
            d.number ,
            d.name deviceName,
            d.specification,
            count(serial_no) zmNum,
            (
                select
                    count(1)
                from
                    device_stocktaking_record dsr
                where
                    dsr.class_id = d.class_id
                  and dsr.abnormal_marking = 0) pdNum
        from
            device_inventory di
                join device d on
                d.id = di.device_id
                join device_class dc on
                d.class_id = dc.id
        where
            di.del_flag = '0'
          and exists (
                select
                    *
                from
                    device_stocktaking_plan_scope dsps
                where
                    dsps.class_id = d.class_id
                  and dsps.plan_id = #{id}
            )
        group by
            d.class_id ,
            dc.name ,
            d.number ,
            d.name,
            d.specification
    </select>
</mapper>