优化出入库汇总的接口,提高查询速度
This commit is contained in:
@@ -187,20 +187,13 @@ public class DepotHeadController {
|
|||||||
depotList.add(object.getLong("id"));
|
depotList.add(object.getLong("id"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<DepotHeadVo4InOutMCount> resList = new ArrayList<>();
|
|
||||||
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
|
||||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||||
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, materialParam,
|
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, materialParam,
|
||||||
depotList, oId, (currentPage-1)*pageSize, pageSize);
|
depotList, oId, (currentPage-1)*pageSize, pageSize);
|
||||||
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId);
|
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId);
|
||||||
map.put("total", total);
|
map.put("total", total);
|
||||||
//存放数据json数组
|
map.put("rows", list);
|
||||||
if (null != list) {
|
|
||||||
for (DepotHeadVo4InOutMCount dhc : list) {
|
|
||||||
resList.add(dhc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
map.put("rows", resList);
|
|
||||||
res.code = 200;
|
res.code = 200;
|
||||||
res.data = map;
|
res.data = map;
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
|
|||||||
@@ -303,20 +303,17 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findInOutMaterialCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultInOutMaterialCount">
|
<select id="findInOutMaterialCount" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultInOutMaterialCount">
|
||||||
select di.material_id, m.bar_code, m.mName,m.Model,m.standard,m.categoryName,m.materialUnit,
|
select di.material_id, me.bar_code, m.name mName,m.Model,m.standard,mc.name categoryName,concat_ws('', m.unit, u.basic_unit) materialUnit,
|
||||||
sum(di.basic_number) numSum,
|
sum(di.basic_number) numSum,
|
||||||
sum(di.all_price) priceSum
|
sum(di.all_price) priceSum
|
||||||
from jsh_depot_head dh
|
from jsh_depot_head dh
|
||||||
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
||||||
left join (select jsh_material.id,jsh_material.name mName, me.bar_code, Model, standard,
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
||||||
jsh_material_category.`Name` categoryName, concat_ws('', jsh_material.unit, u.basic_unit) materialUnit
|
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
from jsh_material
|
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
left join jsh_unit u on jsh_material.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
|
left join jsh_material_category mc on m.category_id=mc.Id and ifnull(mc.delete_flag,'0') !='1'
|
||||||
left join jsh_material_extend me on me.material_id=jsh_material.id and ifnull(me.delete_Flag,'0') !='1'
|
where me.default_flag=1
|
||||||
left join jsh_material_category on jsh_material.category_id=jsh_material_category.Id and ifnull(jsh_material_category.delete_flag,'0') !='1'
|
and (dh.type=#{type} or dh.sub_type='调拨') and dh.oper_time >=#{beginTime} and dh.oper_time <=#{endTime}
|
||||||
where me.default_flag=1 and ifnull(jsh_material.delete_Flag,'0') !='1'
|
|
||||||
) m
|
|
||||||
on m.Id=di.material_id where (dh.type=#{type} or dh.sub_type='调拨') and dh.oper_time >=#{beginTime} and dh.oper_time <=#{endTime}
|
|
||||||
<if test="oId != null">
|
<if test="oId != null">
|
||||||
and dh.organ_id = #{oId}
|
and dh.organ_id = #{oId}
|
||||||
</if>
|
</if>
|
||||||
@@ -354,14 +351,12 @@
|
|||||||
|
|
||||||
<select id="findInOutMaterialCountTotal" resultType="java.lang.Integer">
|
<select id="findInOutMaterialCountTotal" resultType="java.lang.Integer">
|
||||||
select count(1) from
|
select count(1) from
|
||||||
(select di.material_id, m.mName,m.bar_code,m.Model,m.standard,m.categoryName from jsh_depot_head dh
|
(select di.material_id from jsh_depot_head dh
|
||||||
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
left join jsh_depot_item di on dh.id=di.header_id and ifnull(di.delete_flag,'0') !='1'
|
||||||
left join (select jsh_material.id,jsh_material.name mName, me.bar_code, Model,standard,jsh_material_category.`Name` categoryName
|
left join jsh_material m on m.id=di.material_id and ifnull(m.delete_flag,'0') !='1'
|
||||||
from jsh_material
|
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_flag,'0') !='1'
|
||||||
left join jsh_material_extend me on me.material_id=jsh_material.id and ifnull(me.delete_Flag,'0') !='1'
|
where me.default_flag=1
|
||||||
left join jsh_material_category on jsh_material.category_id=jsh_material_category.Id and ifnull(jsh_material_category.delete_flag,'0') !='1'
|
and (dh.type=#{type} or dh.sub_type='调拨') and dh.oper_time >=#{beginTime} and dh.oper_time <=#{endTime}
|
||||||
where me.default_flag=1 and ifnull(jsh_material.delete_Flag,'0') !='1'
|
|
||||||
) m on m.Id=di.material_id where (dh.type=#{type} or dh.sub_type='调拨') and dh.oper_time >=#{beginTime} and dh.oper_time <=#{endTime}
|
|
||||||
<if test="oId != null">
|
<if test="oId != null">
|
||||||
and dh.organ_id = #{oId}
|
and dh.organ_id = #{oId}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user