智慧农业后台管理
tangzy
2022-05-16 f5e7329bfc638dcf686ef25e77172649c8c0f7c6
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
<?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="org.springblade.modules.stockrecord.mapper.StockrecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="stockrecordResultMap" type="org.springblade.modules.stockrecord.entity.Stockrecord">
        <result column="id" property="id"/>
        <result column="stock_id1" property="stockId1"/>
        <result column="amount1" property="amount1"/>
        <result column="time1" property="time1"/>
        <result column="type1" property="type1"/>
        <result column="operator1" property="operator1"/>
        <result column="spn1" property="spn1"/>
        <result column="stock_type1" property="stockType1"/>
        <result column="picture1" property="picture1"/>
        <result column="remarks1" property="remarks1"/>
    </resultMap>
 
 
    <select id="selectStockrecordPage" resultMap="stockrecordResultMap">
        select *
        from sys_stockrecord
        where is_deleted = 0
    </select>
    <select id="seletList" resultType="org.springblade.modules.stock.vo.StockVO">
        SELECT st.*,
        stf.type as stype,
        stf.factory_name as factoryName,
        d.dict_value as dic1,
        c.dict_value as dic2
        FROM `sys_stock` st
        LEFT JOIN sys_stockfactory stf ON st.stock_id = stf.id
        LEFT JOIN (SELECT dict_key,dict_value FROM blade_dict_biz WHERE `code`='stockSpecs1' AND is_deleted=0) d ON
        d.dict_key=st.specs_value1
        LEFT JOIN (SELECT dict_key,dict_value FROM blade_dict_biz WHERE `code`='stockSpecs2' AND is_deleted=0) c ON
        c.dict_key=st.specs_value2
        WHERE st.is_deleted = 0
        <if test="stock.stype!=null and stock.stype != ''">
            and stf.type = #{stock.stype}
        </if>
        <if test="stock.specsValue1!=null and stock.specsValue1 != ''">
            and st.specs_value1 = #{stock.specsValue1}
        </if>
        <if test="stock.specsValue2!=null and stock.specsValue2 != ''">
            and st.specs_value2 = #{stock.specsValue2}
        </if>
        <if test="stock.type!=null and stock.type!= ''">
            and st.type = #{stock.type}
        </if>
        <if test="stock.state!=null and stock.state!= ''">
            and st.state = #{stock.state}
        </if>
    </select>
 
 
    <!--农资记录查询-->
    <select id="seletStockRecordList" resultType="org.springblade.modules.stockrecord.vo.StockrecordVO">
        SELECT st.*,
               stf.type         AS stype,
               stf.factory_name AS factoryName,
               d.dict_value     AS dic1,
               c.dict_value     AS dic2,
               a.name           as czr
        FROM `sys_stockrecord` st
                 LEFT JOIN sys_stockfactory stf
                           ON st.stock_id1 = stf.id
                 LEFT JOIN (SELECT dict_key, dict_value
                            FROM blade_dict_biz
                            WHERE `code` = 'stockSpecs1'
                              AND is_deleted = 0) d ON d.dict_key = st.specs_val1
                 LEFT JOIN (SELECT dict_key, dict_value
                            FROM blade_dict_biz
                            WHERE `code` = 'stockSpecs2'
                              AND is_deleted = 0) c ON c.dict_key = st.specs_val2
                 LEFT JOIN (SELECT name, id FROM blade_user WHERE is_deleted = 0) a ON a.id = st.create_user
        WHERE st.is_deleted = 0
    </select>
</mapper>