优化报表分组sql
This commit is contained in:
@@ -33,6 +33,14 @@
|
||||
<result column="UName" jdbcType="VARCHAR" property="UName" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap extends="BaseResultMap" id="ResultByMaterial" type="com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx">
|
||||
<result column="MId" jdbcType="VARCHAR" property="MId" />
|
||||
<result column="MName" jdbcType="VARCHAR" property="MName" />
|
||||
<result column="MModel" jdbcType="VARCHAR" property="MModel" />
|
||||
<result column="MaterialUnit" jdbcType="VARCHAR" property="MaterialUnit" />
|
||||
<result column="MColor" jdbcType="VARCHAR" property="MColor" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByConditionDepotItem" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="BaseResultMap">
|
||||
select *
|
||||
FROM jsh_depotitem
|
||||
@@ -130,35 +138,35 @@
|
||||
order by di.id asc
|
||||
</select>
|
||||
|
||||
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
|
||||
select di.*, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor
|
||||
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||
select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor
|
||||
from jsh_depotitem di
|
||||
inner join jsh_material m on di.MaterialId=m.id
|
||||
where 1=1
|
||||
<if test="headIds != null">
|
||||
and HeaderId in (${headIds})
|
||||
and di.HeaderId in (${headIds})
|
||||
</if>
|
||||
<if test="materialIds != null">
|
||||
and MaterialId in (${materialIds})
|
||||
and di.MaterialId in (${materialIds})
|
||||
</if>
|
||||
group by MaterialId
|
||||
group by m.id,m.Name, m.Model, m.Unit, m.Color
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findByAllCount" resultType="java.lang.Integer">
|
||||
select count(1) from (select di.Id
|
||||
select count(1) from (select m.id
|
||||
from jsh_depotitem di
|
||||
inner join jsh_material m on di.MaterialId=m.id
|
||||
where 1=1
|
||||
<if test="headIds != null">
|
||||
and HeaderId in (${headIds})
|
||||
and di.HeaderId in (${headIds})
|
||||
</if>
|
||||
<if test="materialIds != null">
|
||||
and MaterialId in (${materialIds})
|
||||
and di.MaterialId in (${materialIds})
|
||||
</if>
|
||||
group by MaterialId) cc
|
||||
group by m.id) cc
|
||||
</select>
|
||||
|
||||
<select id="findByTypeInIsPrev" resultType="java.lang.Double">
|
||||
|
||||
Reference in New Issue
Block a user