智慧农业后台管理
tangzy
2022-05-19 67273fc4b73a4abf62c4c01269d358cf933ca52e
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
<?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.stock.mapper.StockMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="stockResultMap" type="org.springblade.modules.stock.entity.Stock">
        <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_id" property="stockId"/>
        <result column="specs" property="specs"/>
        <result column="specs_value1" property="specsValue1"/>
        <result column="specs_value2" property="specsValue2"/>
        <result column="amount" property="amount"/>
        <result column="type" property="type"/>
        <result column="time" property="time"/>
        <result column="picture" property="picture"/>
        <result column="remarks" property="remarks"/>
        <result column="state" property="state"/>
    </resultMap>
 
 
    <select id="selectStockPage" resultMap="stockResultMap">
        select *
        from sys_stock
        where is_deleted = 0
    </select>
 
    <select id="selectLists" resultType="org.springblade.modules.stock.vo.StockVO">
        SELECT st.*,
        stf.factory_name AS factoryName,
        stf.type AS stype,
        d.dict_value AS dic1,
        c.dict_value AS dic2
        FROM sys_stock st
        LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_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.state!=null and stock.state != ''">
            and st.state = #{stock.state}
        </if>
        <if test="stock.type!=null and stock.type != ''">
            and st.type = #{stock.type}
        </if>
    </select>
    <!--入库出库-->
    <update id="UpdaeAmountc">
        update sys_stock set amount = #{stock.amount} ,state=#{stock.state} where stock_id=#{stock.stockId}
    </update>
 
</mapper>