入库查询物料优化

This commit is contained in:
z 2025-03-09 21:46:00 +08:00
parent a91cb9af0a
commit 3c4205304a
5 changed files with 44 additions and 45 deletions

View File

@ -148,4 +148,6 @@ public class ProcessBomDetailDO extends BaseDO {
private String matType;
@TableField(exist = false)
private BigDecimal price;
@TableField(exist = false)
private String matUnitId;
}

View File

@ -127,29 +127,31 @@ public class StorageLogServiceImpl implements StorageLogService {
@Override
public PageResult<StorageMaterialDO> getStorageNowPageGroupMaterial(StorageLogPageReqVO pageReqVO) {
PageResult<StorageMaterialDO> pageResult = storageMaterialMapper.selectMaterialGroupNow(pageReqVO);
if (ObjectUtil.isNotEmpty(pageReqVO.getWhId())){
// 获取所有物料编码
List<String> matCodes = pageResult.getList().stream()
.map(StorageMaterialDO::getMatCode)
.collect(Collectors.toList());
// 批量查询库存日志
LambdaQueryWrapper<StorageLogNowDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StorageLogNowDO::getWhId, pageReqVO.getWhId())
.in(StorageLogNowDO::getMatCode, matCodes);
List<StorageLogNowDO> logList = storageLogNowMapper.selectList(wrapper);
if (ObjectUtil.isNotEmpty(pageReqVO.getWhId())) {
if (ObjectUtil.isNotEmpty(pageResult.getList())) {
// 获取所有物料编码
List<String> matCodes = pageResult.getList().stream()
.map(StorageMaterialDO::getMatCode)
.collect(Collectors.toList());
// 批量查询库存日志
LambdaQueryWrapper<StorageLogNowDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StorageLogNowDO::getWhId, pageReqVO.getWhId())
.in(StorageLogNowDO::getMatCode, matCodes);
List<StorageLogNowDO> logList = storageLogNowMapper.selectList(wrapper);
// 将库存日志按物料编码分组
Map<String, List<StorageLogNowDO>> logMap = logList.stream()
.collect(Collectors.groupingBy(StorageLogNowDO::getMatCode));
// 将库存日志按物料编码分组
Map<String, List<StorageLogNowDO>> logMap = logList.stream()
.collect(Collectors.groupingBy(StorageLogNowDO::getMatCode));
// 计算每个物料的剩余数量并设置到对应的 StorageMaterialDO 对象中
for (StorageMaterialDO storageMaterialDO : pageResult.getList()) {
List<StorageLogNowDO> logs = logMap.getOrDefault(storageMaterialDO.getMatCode(), Collections.emptyList());
BigDecimal matRest = logs.stream()
.map(StorageLogNowDO::getStorageOkQty)
.filter(Objects::nonNull) // 确保过滤掉 null
.reduce(BigDecimal.ZERO, BigDecimal::add);
storageMaterialDO.setMatRest(matRest);
// 计算每个物料的剩余数量并设置到对应的 StorageMaterialDO 对象中
for (StorageMaterialDO storageMaterialDO : pageResult.getList()) {
List<StorageLogNowDO> logs = logMap.getOrDefault(storageMaterialDO.getMatCode(), Collections.emptyList());
BigDecimal matRest = logs.stream()
.map(StorageLogNowDO::getStorageOkQty)
.filter(Objects::nonNull) // 确保过滤掉 null
.reduce(BigDecimal.ZERO, BigDecimal::add);
storageMaterialDO.setMatRest(matRest);
}
}
}
return pageResult;

View File

@ -270,7 +270,7 @@
</el-form>
<div class="text-center hl-footer">
<el-button @click="() => router.back()" size="large"> </el-button>
<el-button @click="submitForm" type="success" size="large"> </el-button>
<!-- <el-button @click="submitForm" type="success" size="large"> </el-button>-->
</div>
</el-card>

View File

@ -50,15 +50,15 @@
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['heli:shenhe:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- @click="handleExport"-->
<!-- :loading="exportLoading"-->
<!-- v-hasPermi="['heli:shenhe:export']"-->
<!-- >-->
<!-- <Icon icon="ep:download" class="mr-5px" /> 导出-->
<!-- </el-button>-->
</el-form-item>
</el-form>
</ContentWrap>
@ -67,7 +67,7 @@
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border class="hl-table">
<el-table-column type="index" min-width="70" fixed label="序号" align="center" />
<el-table-column type="index" width="70" fixed label="序号" align="center" />
<el-table-column v-if="false" label="项目ID" align="center" prop="id" width="240px" />
@ -76,13 +76,13 @@
<el-table-column label="客户全称" align="center" prop="customerName" width="240px"/>
<el-table-column label="子项目Id" v-if="false" align="center" prop="projectSubId" />
<el-table-column label="子项目名称" align="center" prop="projectSubName" width="200px"/>
<el-table-column label="标准件成本(元)" align="center" prop="biaoZhunJianCost" width="100px"/>
<el-table-column label="其他成本(元)" align="center" prop="qitaCost" width="100px"/>
<el-table-column label="标准件成本(元)" align="center" prop="biaoZhunJianCost" width="200px"/>
<el-table-column label="其他成本(元)" align="center" prop="qitaCost" width="200px"/>
<!-- <el-table-column label="副资材成本" align="center" prop="fuZiCaiCost" />-->
<!-- <el-table-column label="外协加工费用" align="center" prop="waiXieCost" />-->
<el-table-column label="加工工时换算成本(元)" align="center" prop="jiaGongShiCost" width="100px"/>
<el-table-column label="运费成本(元)" align="center" prop="yunFeiCost" width="100px"/>
<el-table-column label="合计成本(元)" align="center" prop="sumCost" width="100px"/>
<el-table-column label="加工工时换算成本(元)" align="center" prop="jiaGongShiCost" width="220px"/>
<el-table-column label="运费成本(元)" align="center" prop="yunFeiCost" width="200px"/>
<el-table-column label="合计成本(元)" align="center" prop="sumCost" width="200px"/>
<el-table-column fixed="right" label="操作" align="center" width="150">
@ -90,7 +90,7 @@
<el-row>
<el-col>
<el-button link type="primary" @click="openForm(scope.row.id,scope.row.projectSubId)">
编辑
详情
</el-button>
</el-col>

View File

@ -197,7 +197,7 @@ class="!w-265px" placeholder="物料编码" :disabled="true || ctrView || ctrSav
<template #default="scope">
<dict-tag
:type="DICT_TYPE.HELI_MATERIAL_UNIT" :value="scope.row.matUnit"
v-if="scope.row.matUnit ? true : false" />
/>
</template>
</el-table-column>
<el-table-column prop="rgId" min-width="120" align="center">
@ -509,7 +509,6 @@ const openProjectForm = (scope) => {
const getList = async (arrMat) => {
console.log(JSON.stringify(arrMat))
arrMat.forEach((row) => {
if (
formData.value.matItemDOList.filter(
@ -542,13 +541,9 @@ const getList = async (arrMat) => {
if(row.materialTypeId!=null){
row.matType = row.materialTypeId
}
if(formData.value.pickmode==1 && row.matUnitId!=null){
if(row.matUnitId!=null){
row.matUnit = row.matUnitId
}
if(row.matUnit == '公斤'){
row.matUnit = 4
}
console.log(row)
formData.value.matItemDOList.push(row)
}
})