<?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.mzl.flower.mapper.statisticsAnalysis.FlowerMaterialMapper">
|
|
|
<select id="getFlowerMaterialPage"
|
resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerMaterialVO">
|
<!-- <include refid="flowerMaterialSql"></include>-->
|
<include refid="flowerMaterialSqlWidthDict"></include>
|
</select>
|
<select id="getFlowerMaterialList"
|
resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerMaterialVO">
|
<include refid="flowerMaterialSqlWidthDict"></include>
|
</select>
|
<select id="getFlowerMaterialStatis"
|
resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerMaterialStaticVO">
|
select
|
count(distinct si.id) as supplier_amount,
|
count(f.id) as flower_amount,
|
sum(f.stock) as flower_stock_amount
|
from t_flower f
|
left join t_supplier_info si
|
on f.supplier_id=si.id
|
left join t_user u
|
on si.user_id =u.id
|
left join t_station s
|
on si.station_id=s.id
|
left join t_flower_category fc
|
on f.category=fc.id
|
<include refid="flowerMaterialSql_where"></include>
|
</select>
|
|
<sql id="flowerMaterialSql">
|
select
|
si.id as supplier_id
|
,si.name as supplier_name
|
,u.login_name
|
,si.contact_tel
|
,s.name as station_name
|
,fc.name as category_name
|
,case when fc_parent.id is not null then fc_parent.name else fc.name end as parent_category_name
|
,f.name as flower_name
|
,f.`level` as flower_level
|
,f.unit as flower_unit
|
,f.price as flower_price
|
,f.stock flower_stock
|
,f.status as flower_status
|
from t_flower f
|
left join t_supplier_info si
|
on f.supplier_id=si.id
|
left join t_user u
|
on si.user_id =u.id
|
left join t_station s
|
on si.station_id=s.id
|
left join t_flower_category fc
|
on f.category=fc.id
|
left join t_flower_category fc_parent
|
on fc.parent_id=fc_parent.id
|
-- and u.deleted=0 and s.deleted=0 and fc.deleted=0
|
<include refid="flowerMaterialSql_where"></include>
|
<if test="dto.orderField !=null and dto.orderField !=''">
|
order by ${dto.orderField} ${dto.orderType}
|
</if>
|
</sql>
|
|
<sql id="flowerMaterialSqlWidthDict">
|
select
|
si.id as supplier_id
|
,si.name as supplier_name
|
,u.login_name
|
,si.contact_tel
|
,s.name as station_name
|
,fc.name as category_name
|
,case when fc_parent.id is not null then fc_parent.name else fc.name end as parent_category_name
|
,f.name as flower_name
|
,f.`level` as flower_level
|
,f.unit as flower_unit
|
,f.price as flower_price
|
,f.stock flower_stock
|
,f.status as flower_status
|
,code.label as flower_status_str
|
, code2.label as flower_level_str
|
from t_flower f
|
left join t_supplier_info si
|
on f.supplier_id=si.id
|
left join t_user u
|
on si.user_id =u.id
|
left join t_station s
|
on si.station_id=s.id
|
left join t_flower_category fc
|
on f.category=fc.id
|
left join t_flower_category fc_parent
|
on fc.parent_id=fc_parent.id
|
LEFT JOIN (SELECT ct.label, ct.value from t_code_value ct where type_code = 'FLOWER_STATUS') code ON f.status = code.value
|
LEFT JOIN (SELECT ct.label, ct.value from t_code_value ct where type_code = 'FLOWER_LEVEL') code2 ON f.`level` = code2.value
|
<include refid="flowerMaterialSql_where"></include>
|
<if test="dto.orderField !=null and dto.orderField !=''">
|
order by ${dto.orderField} ${dto.orderType}
|
</if>
|
</sql>
|
|
<sql id="flowerMaterialSql_where">
|
where f.deleted=0 and si.deleted =0
|
<if test="dto.supplierId != null">
|
and f.supplier_id = #{dto.supplierId}
|
</if>
|
<if test="dto.supplierName !=null and dto.supplierName !=''">
|
AND si.name LIKE concat('%', #{dto.supplierName},'%')
|
</if>
|
<if test="dto.loginName !=null and dto.loginName !=''">
|
AND u.login_name LIKE concat('%', #{dto.loginName},'%')
|
</if>
|
|
<if test="dto.contactTel !=null and dto.contactTel !=''">
|
AND si.contact_tel LIKE concat('%', #{dto.contactTel},'%')
|
</if>
|
|
<if test="dto.stationId !=null and dto.stationId !=''">
|
AND si.station_id = #{dto.stationId}
|
</if>
|
|
<if test="dto.flowerCategory !=null and dto.flowerCategory !=''">
|
AND ( f.category = #{dto.flowerCategory} or f.category in (
|
select id from t_flower_category where parent_id = #{dto.flowerCategory}
|
))
|
|
</if>
|
<!-- <if test="dto.flowerStatus != null and dto.flowerStatus != ''">-->
|
<!-- <if test="dto.flowerStatus == 'OFF'">-->
|
<!-- AND f.status IN ('OFF', 'FORCE_OFF')-->
|
<!-- </if>-->
|
<!-- <if test="dto.flowerStatus != 'OFF'">-->
|
<!-- AND f.status = #{dto.flowerStatus}-->
|
<!-- </if>-->
|
<!-- </if>-->
|
|
<if test="dto.flowerStatus != null and dto.flowerStatus != ''">
|
AND f.status = #{dto.flowerStatus}
|
</if>
|
<if test="dto.flowerLevel !=null and dto.flowerLevel !=''">
|
AND f.`level` = #{dto.flowerLevel}
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
</mapper>
|