rev:日库存统计增加:入库数、出库数

This commit is contained in:
2023-10-09 11:21:59 +08:00
parent dbb70827d8
commit ad8df52dcf
5 changed files with 102 additions and 2 deletions

View File

@@ -110,7 +110,15 @@ public class StIvtStructivtDaily implements Serializable {
*/
private BigDecimal warehousing_qty;
/**
* 入库数
*/
private BigDecimal in_qty;
/**
* 出库数
*/
private BigDecimal out_qty;
}

View File

@@ -23,10 +23,16 @@ public interface StIvtStructivtDailyMapper extends BaseMapper<StIvtStructivtDail
List<Map> selectStructivt(@Param("table") String table);
/**
* 大屏数据 - 近一周工段产量
* 获取历史库存
* @param list /
* @return /
*/
List<JSONObject> getHistoryivt(@Param("chanList") List<String> list, @Param("query") Map json);
/**
* 获取当天出入库数量
* @return /
*/
List<JSONObject> getIoNum(@Param("query") Map json);
}

View File

@@ -29,4 +29,58 @@
</where>
</select>
<select id="getIoNum" resultType="com.alibaba.fastjson.JSONObject">
SELECT
dis.material_id,
SUM(dis.plan_qty) AS io_num
FROM
st_ivt_iostorinvdis_yl dis
LEFT JOIN st_ivt_iostorinv_yl mst ON dis.iostorinv_id = mst.iostorinv_id
WHERE
mst.is_delete = '0'
and LEFT(mst.confirm_time,10) = CURDATE()
<if test="query.io_type != null and query.io_type != ''">
and mst.io_type = #{query.io_type}
</if>
group by dis.material_id
UNION
SELECT
dis.material_id,
SUM(dis.plan_qty) AS io_num
FROM
st_ivt_iostorinvdis_cp dis
LEFT JOIN st_ivt_iostorinv_cp mst ON dis.iostorinv_id = mst.iostorinv_id
WHERE
mst.is_delete = '0'
and LEFT(mst.confirm_time,10) = CURDATE()
<if test="query.io_type != null and query.io_type != ''">
and mst.io_type = #{query.io_type}
</if>
group by dis.material_id
UNION
SELECT
mst.material_id,
SUM(mst.plan_qty) AS io_num
FROM
st_ivt_iostorinv_bcp mst
WHERE
mst.is_delete = '0'
and LEFT(mst.update_time,10) = CURDATE()
<if test="query.io_type != null and query.io_type != ''">
and mst.io_type = #{query.io_type}
</if>
group by mst.material_id
</select>
</mapper>

View File

@@ -2,8 +2,10 @@ package org.nl.wms.masterdata_manage.storage.service.dailyStructivt.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
@@ -15,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -48,6 +51,35 @@ public class StIvtStructivtDailyServiceImpl extends ServiceImpl<StIvtStructivtDa
list.addAll(dailyList);
}
}
/*
* 统计今日入库数、出库数
*/
JSONObject param = new JSONObject();
// 入库数
param.put("io_type", "0");
List<JSONObject> inNumList = this.baseMapper.getIoNum(param);
// 出库数
param.put("io_type", "1");
List<JSONObject> outNumList = this.baseMapper.getIoNum(param);
// 整理数据
for (StIvtStructivtDaily dao : list) {
List<JSONObject> jsonIn = inNumList.stream()
.filter(row -> row.getString("material_id").equals(dao.getMaterial_id()))
.collect(Collectors.toList());
dao.setIn_qty(ObjectUtil.isNotEmpty(jsonIn) ? jsonIn.get(0).getBigDecimal("io_num") : BigDecimal.valueOf(0));
List<JSONObject> jsonOut = outNumList.stream()
.filter(row -> row.getString("material_id").equals(dao.getMaterial_id()))
.collect(Collectors.toList());
dao.setOut_qty(ObjectUtil.isNotEmpty(jsonOut) ? jsonOut.get(0).getBigDecimal("io_num") : BigDecimal.valueOf(0));
}
if (!CollectionUtils.isEmpty(list)){
List<StIvtStructivtDaily> errorData = list.stream().filter(stIvtStructivtDaily -> StringUtils.isEmpty(stIvtStructivtDaily.getStor_id()) || StringUtils.isEmpty(stIvtStructivtDaily.getMaterial_id())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(errorData)){

View File

@@ -87,7 +87,7 @@
<pagination />
</el-col>
</el-row>
<hr/>
<el-row :gutter="20">
<el-col :xs="24" :sm="24" :lg="24">
<div class="chart-wrapper">