智慧农业后台管理
guoshilong
2022-11-08 72b971c98c46531064d74b68fc8fe8864ed0b544
src/main/java/org/springblade/modules/InventoryLoss/mapper/InventoryMapper.xml
@@ -3,16 +3,36 @@
<mapper namespace="org.springblade.modules.InventoryLoss.mapper.InventoryMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="inventoryResultMap" type="org.springblade.modules.InventoryLoss.entity.Inventory">
    <resultMap id="inventoryResultMap" type="org.springblade.modules.InventoryLoss.vo.InventoryVO">
        <result column="id" property="id"/>
        <result column="strain_name" property="strainName"/>
        <result column="dict_value" property="reasonName"/>
    </resultMap>
    <select id="selectSalePage" resultMap="inventoryResultMap">
        select *
        from sys_inventory
        where is_deleted = 0
        select inventory.*,
               strain.strain_name,mach.machining_type AS proName,bdb.dict_value
        from sys_inventory inventory
        LEFT JOIN sys_strain strain on inventory.strain_id = strain.id
        LEFT JOIN blade_dict_biz bdb ON inventory.reason = bdb.dict_key
        LEFT JOIN sys_land land ON land.id = inventory.land_id
        LEFT JOIN sys_process_inv inv ON inv.id = inventory.prod_id
        LEFT JOIN sys_machining mach ON mach.id = inv.product_id
        where
        1=1
        <if test="inventory.farmId != null and inventory.farmId !=''">
            AND (land.farm_id = #{inventory.farmId} OR inv.fps_id = #{inventory.farmId})
        </if>
        <if test="inventory.type != null and inventory.type !='' ">
            AND inventory.type = #{inventory.type}
        </if>
        <if test="inventory.kind != null and inventory.kind !='' ">
            AND (inv.product_id = #{inventory.kind} OR inventory.strain_id = #{inventory.kind})
        </if>
            AND bdb.code = "lossReason"
            AND inventory.is_deleted = 0
            ORDER BY inventory.create_time DESC
    </select>
</mapper>