耗材数据统计
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.czg.service.product.mapper;
|
||||
|
||||
import com.czg.product.entity.ConsStockFlow;
|
||||
import com.czg.product.param.ConsInfoParam;
|
||||
import com.czg.product.vo.ConsStatisticsVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -12,5 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface ConsStockFlowMapper extends BaseMapper<ConsStockFlow> {
|
||||
|
||||
ConsStatisticsVo getConsStatistics(ConsInfoParam param);
|
||||
}
|
||||
@@ -12,13 +12,12 @@ import com.czg.product.dto.ProductBriefDTO;
|
||||
import com.czg.product.entity.ConsGroup;
|
||||
import com.czg.product.entity.ConsGroupRelation;
|
||||
import com.czg.product.entity.ConsInfo;
|
||||
import com.czg.product.param.ConsInfoParam;
|
||||
import com.czg.product.param.ConsSubUnitParam;
|
||||
import com.czg.product.service.ConsInfoService;
|
||||
import com.czg.product.vo.ConsStatisticsVo;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ConsGroupMapper;
|
||||
import com.czg.service.product.mapper.ConsGroupRelationMapper;
|
||||
import com.czg.service.product.mapper.ConsInfoMapper;
|
||||
import com.czg.service.product.mapper.ProdConsRelationMapper;
|
||||
import com.czg.service.product.mapper.*;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -46,6 +45,7 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
private final ConsGroupRelationMapper consGroupRelationMapper;
|
||||
private final ProdConsRelationMapper prodConsRelationMapper;
|
||||
private final ConsGroupMapper consGroupMapper;
|
||||
private final ConsStockFlowMapper consStockFlowMapper;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(ConsInfoDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
@@ -205,4 +205,13 @@ public class ConsInfoServiceImpl extends ServiceImpl<ConsInfoMapper, ConsInfo> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsStatisticsVo statistics(ConsInfoParam param) {
|
||||
ConsStatisticsVo data = consStockFlowMapper.getConsStatistics(param);
|
||||
if (data == null) {
|
||||
data = new ConsStatisticsVo();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,4 +3,36 @@
|
||||
|
||||
<mapper namespace="com.czg.service.product.mapper.ConsStockFlowMapper">
|
||||
|
||||
<select id="getConsStatistics" resultType="com.czg.product.vo.ConsStatisticsVo">
|
||||
SELECT
|
||||
sum( CASE WHEN t1.in_out_type = 'in' then t1.in_out_number end) AS inSumTotal,
|
||||
sum( CASE WHEN t1.in_out_item = 'win-in' THEN t1.in_out_number END ) AS winInNum,
|
||||
sum( CASE WHEN t1.in_out_item = 'manual-in' THEN t1.in_out_number END ) AS stockInNum,
|
||||
sum( CASE WHEN t1.in_out_type = 'out' then abs(t1.in_out_number) end) AS outSumTotal,
|
||||
sum( CASE WHEN t1.in_out_item = 'loss-out' THEN abs(t1.in_out_number) END ) AS lossOutNum,
|
||||
sum( CASE WHEN t1.in_out_item = 'order-out' THEN abs(t1.in_out_number) END ) AS consumeNum,
|
||||
sum( CASE WHEN t1.in_out_item = 'damage-out' THEN abs(t1.in_out_number) END ) AS damageNum,
|
||||
sum( CASE WHEN t1.in_out_item = 'manual-out' THEN abs(t1.in_out_number) END ) AS stockOutNum
|
||||
FROM
|
||||
tb_cons_stock_flow t1
|
||||
LEFT JOIN tb_cons_info t2 on t1.con_id = t2.id
|
||||
where t1.shop_id = #{shopId}
|
||||
<if test="id != null">
|
||||
and t1.con_id = #{id}
|
||||
</if>
|
||||
<if test="consGroupId != null">
|
||||
and t2.cons_group_id = #{consGroupId}
|
||||
</if>
|
||||
<if test="conName != null and conName != ''">
|
||||
and t1.con_name like concat('%', #{conName}, '%')
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
and t1.create_time >= str_to_date(#{beginTime}, '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
<![CDATA[
|
||||
and t1.create_time <= str_to_date(#{endTime}, '%Y-%m-%d %H:%i:%s')
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user