智慧农业后台管理
guoshilong
2022-08-18 fe371739b664c4e87914bcc7f3f550fec7e93121
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?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.soldr.mapper.SoldrMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="soldrResultMap" type="org.springblade.modules.soldr.entity.Soldr">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="stock_id1" property="stockId1"/>
        <result column="amount1" property="amount1"/>
        <result column="tenant_id1" property="tenantId1"/>
        <result column="specs1" property="specs1"/>
        <result column="specs_val1" property="specsVal1"/>
        <result column="specs_val2" property="specsVal2"/>
        <result column="type" property="type"/>
    </resultMap>
 
 
    <select id="selectSoldrPage" resultMap="soldrResultMap">
        select *
        from sys_soldr
        where is_deleted = 0
    </select>
 
    <select id="selectLists" resultType="org.springblade.modules.soldr.vo.SoldrVO">
        SELECT st.id,st.stock_id1,
        st.specs1,
        st.sid,
        st.amount1 AS amount1,
        stf.factory_name AS factoryName,
        a.dict_value AS stype,
        d.dict_value AS dic1,
        c.dict_value AS dic2,
        stf.agricultural_name as agrname,
        st.dept_id
        FROM sys_soldr st
        LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
        LEFT JOIN (SELECT dict_key, dict_value
        FROM blade_dict_biz
        WHERE CODE = 'stockSpecs1' AND is_deleted = 0 <if test="soldr.codes!=null and soldr.codes != ''">
        AND blade_dict_biz.tenant_id = #{soldr.codes}
    </if>) 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 <if test="soldr.codes!=null and soldr.codes != ''">
        AND blade_dict_biz.tenant_id = #{soldr.codes}
    </if>) c ON c.dict_key = st.specs_val2
        LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0  <if
        test="soldr.codes!=null and soldr.codes != ''">
        AND blade_dict_biz.tenant_id = #{soldr.codes}
    </if>) a ON
        a.dict_key = stf.type
        WHERE st.is_deleted = 0
        <if test="soldr.stype!=null and soldr.stype != ''">
            and stf.type = #{soldr.stype}
        </if>
        <if test="soldr.stockId1!=null and soldr.stockId1 != ''">
            and st.stock_id1 = #{soldr.stockId1}
        </if>
        <if test="soldr.deptId != null and soldr.deptId !=''">
            AND st.dept_id = #{soldr.deptId}
        </if>
    </select>
 
    <delete id="del">
        delete
        from sys_soldr
        where sid = #{id}
    </delete>
 
    <delete id="dels">
        delete
        from sys_soldr
        where id = #{id}
    </delete>
 
    <!--已出农资列表-->
    <select id="selectSol" resultType="org.springblade.modules.soldr.vo.SoldrVO">
        SELECT st.id,
               st.stock_id1,
               st.specs1,
               st.sid,
               st.amount1            AS amount1,
               stf.factory_name      AS factoryName,
               a.dict_value          AS stype,
               d.dict_value          AS dic1,
               c.dict_value          AS dic2,
               stf.agricultural_name as agrname
        FROM sys_soldr st
                 LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
                 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 dict_key, dict_value
                            FROM blade_dict_biz
                            WHERE CODE = 'stockType' AND is_deleted = 0) a ON
            a.dict_key = stf.type
        WHERE st.is_deleted = 0
        <if test="farmId != null and farmId !=''">
            AND st.dept_id = #{farmId}
        </if>
    </select>
 
    <!--查询是否存在已出库农资-->
    <select id="selectCz" resultType="java.util.Map">
        SELECT census, sid, amount1
        FROM `sys_soldr`
        WHERE sid = #{sid} AND dept_id = #{deptId}
    </select>
<!--    根据stockId、specs1、specs_val1、specs_val2、sid-->
    <select id="getByServalParam" resultType="org.springblade.modules.soldr.entity.Soldr">
        SELECT * FROM sys_soldr WHERE
        stock_id1 = #{stockId1} and specs1=#{specs1} and specs_val1=#{specsVal1} and specs_val2=#{specsVal2} and sid=#{sid} and type=#{type} and is_deleted=0
    </select>
 
    <update id="cancelDel">
        UPDATE sys_soldr SET is_deleted = 0 WHERE id = #{id}
    </update>
 
</mapper>