pad接口-请领单-出库:如果请领的物品数量大于库房库存数量则返回失败结果

This commit is contained in:
1378012178@qq.com 2025-12-10 14:08:50 +08:00
parent ad2a858faa
commit 42f100fd58
1 changed files with 31 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.nu.modules.qld.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.StrBuilder;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -772,13 +773,42 @@ public class QingLingServiceImpl implements IQinglingApi {
String cannotHandleQldNos = Arrays.stream(qldNosArr)
.filter(qldNo -> !invoicingQldLogService.opeNodeJudgeCanStatus(qldNo, "1"))
.collect(Collectors.joining(","));
//检测库房物料数量是否满足请领需求
{
//出库物料汇总
InvoicingQldQueryEntity q_ = new InvoicingQldQueryEntity();
q_.setQldNo(dto.getQldNo());
List<InvoicingQldInfoEntity> qldInfoList = invoicingQldInfoMapper.queryWlInfo(q_);
//库房物料存量
List<BlWarehouseMaterialInfo> kfnumList = warehouseMaterialInfoService.list();
Map<String, String> qldWlNumMap = kfnumList.stream()
.collect(Collectors.toMap(BlWarehouseMaterialInfo::getWlId, BlWarehouseMaterialInfo::getKcsl));
StrBuilder errorWl = new StrBuilder();
for (int i = 0; i < qldInfoList.size(); i++) {
InvoicingQldInfoEntity item = qldInfoList.get(i);
if (qldWlNumMap.get(item.getWlId()) == null || item.getQlNum() > Integer.parseInt(qldWlNumMap.get(item.getWlId()))) {
//请领数量大于库房存量的
if (errorWl.length() > 0) {
errorWl.append("");
}
errorWl.append(item.getMaterialInfo().getMaterialName());
}
}
if (!errorWl.isEmpty()) {
map.put("status", "faild");
map.put("message", "以下物料库存不足,无法出库:" + errorWl);
return map;
}
}
//本次处理单号中 - 可正常出库单号
String normalQldNos = Arrays.stream(qldNosArr)
.filter(qldNo -> !cannotHandleQldNos.contains(qldNo))
.collect(Collectors.joining(","));
if (StringUtils.isBlank(normalQldNos)) {
map.put("status", "faild");
map.put("faildQldNos", cannotHandleQldNos);
map.put("message", "单据错误,请刷新页面");
// map.put("faildQldNos", cannotHandleQldNos);
return map;
}