fix:盘0

This commit is contained in:
zhaoyf
2026-11-27 20:03:44 +08:00
parent d39d268f6a
commit 4fcca69ec9
4 changed files with 44 additions and 28 deletions

View File

@@ -1,9 +1,9 @@
package org.nl.wms.warehouse_manage.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.IdUtil;
import org.nl.wms.warehouse_manage.enums.IOSConstant;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
@@ -84,27 +84,34 @@ public class StIvtCheckdtlServiceImpl extends ServiceImpl<StIvtCheckdtlMapper, S
public void createMore(List<StIvtCheckdtl> dtlDaoList, String check_id) {
StIvtCheckmst mstDao = iStIvtCheckmstService.getById(check_id);
for (StIvtCheckdtl dao : dtlDaoList) {
if (dao.getBase_qty() == null) {
throw new BadRequestException("盘点明细序号【" + dao.getSeq_no() + "】库存数量为空,请检查数据!");
}
if (dao.getFac_qty() == null) {
throw new BadRequestException("盘点明细序号【" + dao.getSeq_no() + "】盘点数量为空,请先完成盘点!");
}
// 组织创建损益单据主数据
MoreOrLessInsertDto moreDto = new MoreOrLessInsertDto();
moreDto.setMol_inv_type(IOSEnum.MORE_MST_TYPE.code("盘点损益"));
// 根据库存数量以及盘点数量来判断损益类型
double base_qty = dao.getBase_qty().doubleValue();
double fac_qty = dao.getFac_qty().doubleValue();
double mol_qty;
if (base_qty == fac_qty) {
// 根据库存数量以及盘点数量来判断损益类型(盘点数量允许为0,为0时按全额盘亏处理)
BigDecimal base_qty = dao.getBase_qty();
BigDecimal fac_qty = dao.getFac_qty();
BigDecimal mol_qty;
int compare = base_qty.compareTo(fac_qty);
if (compare == 0) {
continue;
} else if (base_qty > fac_qty) {
} else if (compare > 0) {
moreDto.setMol_type(IOSEnum.MORE_TYPE.code("损"));
mol_qty = NumberUtil.sub(base_qty, fac_qty);
mol_qty = base_qty.subtract(fac_qty);
} else {
moreDto.setMol_type(IOSEnum.MORE_TYPE.code("溢"));
mol_qty = NumberUtil.sub(fac_qty, base_qty);
mol_qty = fac_qty.subtract(base_qty);
}
moreDto.setBiz_date(DateUtil.today());
moreDto.setDtl_num(BigDecimal.valueOf(1));
moreDto.setStor_id(mstDao.getStor_id());
moreDto.setRemark("由明细标识【"+dao.getCheck_optid()+"】创建");
moreDto.setTotal_qty(BigDecimal.valueOf(mol_qty));
moreDto.setTotal_qty(mol_qty);
moreDto.setCreate_mode(IOSConstant.CREATE_TYPE);
moreDto.setStatus(IOSEnum.MORE_MST_STATUS.code("生成"));

View File

@@ -304,18 +304,25 @@ public class UpdateIvtUtils {
.eq(GroupPlate::getPcsn, where.getString("pcsn"))
);
if (ObjectUtil.isEmpty(extDao)) {
throw new BadRequestException("当前载具【" + extDao.getStoragevehicle_code() + "】不存在相关物料批次库存,请检查数据!");
throw new BadRequestException("当前载具【" + where.getString("storagevehicle_code") + "】不存在相关物料批次库存,请检查数据!");
}
double canuse_qty = NumberUtil.sub(extDao.getQty(), where.getDoubleValue("change_qty")).doubleValue();
if (canuse_qty < 0) {
throw new BadRequestException("可用数不能为负数,请检查变动数量!当前可用数为【" + extDao.getQty() + "】当前变动数为【" + where.getDoubleValue("change_qty") + "】");
BigDecimal change_qty = where.getBigDecimal("change_qty");
BigDecimal current_qty = extDao.getQty() == null ? BigDecimal.ZERO : extDao.getQty();
BigDecimal canuse_qty = current_qty.subtract(change_qty);
if (canuse_qty.compareTo(BigDecimal.ZERO) < 0) {
throw new BadRequestException("可用数不能为负数,请检查变动数量!当前可用数为【" + current_qty + "】当前变动数为【" + change_qty + "】");
}
if (canuse_qty.compareTo(BigDecimal.ZERO) == 0) {
//盘点数量为0等场景:可用数减为0后不再保留0库存数据,直接删除组盘关系记录
iMdPbGroupPlateService.removeById(extDao.getGroup_id());
} else {
extDao.setQty(canuse_qty);
extDao.setUpdate_id(SecurityUtils.getCurrentUserId());
extDao.setUpdate_name(SecurityUtils.getCurrentNickName());
extDao.setUpdate_time(DateUtil.now());
extDao.setRemark(where.getString("remark"));
iMdPbGroupPlateService.updateById(extDao);
}
extDao.setQty(BigDecimal.valueOf(canuse_qty));
extDao.setUpdate_id(SecurityUtils.getCurrentUserId());
extDao.setUpdate_name(SecurityUtils.getCurrentNickName());
extDao.setUpdate_time(DateUtil.now());
extDao.setRemark(where.getString("remark"));
iMdPbGroupPlateService.updateById(extDao);
//获取仓位信息
Structattr structattr = structattrService.getOne(new LambdaQueryWrapper<Structattr>()
.eq(Structattr::getStruct_code, where.getString("struct_code")));
@@ -326,8 +333,8 @@ public class UpdateIvtUtils {
record.setVehicle_code(extDao.getStoragevehicle_code());
record.setMaterial_id(extDao.getMaterial_code());
record.setPcsn(extDao.getPcsn());
record.setQty(extDao.getQty());
record.setChange_qty(where.getBigDecimal("change_qty"));
record.setQty(canuse_qty);
record.setChange_qty(change_qty);
record.setSource_form_id(extDao.getExt_code());
record.setUnit_id(extDao.getQty_unit_id());
record.setStruct_code(structattr.getStruct_code());

View File

@@ -182,11 +182,10 @@
<el-form :model="reverseForm" size="mini" label-width="100px" label-suffix=":">
<el-form-item label="入库方式">
<el-radio-group v-model="reverseForm.inbound_mode">
<el-radio label="FLAT">平库</el-radio>
<el-radio label="FLAT">平库\中鼎</el-radio>
<el-radio label="SHELF">货架</el-radio>
</el-radio-group>
</el-form-item>
<el-alert title="入中鼎选平库即可,自动推中鼎。" type="info" :closable="false" show-icon />
<el-alert v-if="reverseForm.inbound_mode === 'FLAT'" title="平库按仓库编码作为库区编码,仓库固定库位和固定托盘永久绑定,入库后直接完成。" type="info" :closable="false" show-icon />
<template v-else>
<el-form-item label="托盘码">

View File

@@ -289,7 +289,7 @@ export default {
const num = parseFloat(row.base_qty)
const fac_qty = parseFloat(row.fac_qty)
if (num <= 0 && fac_qty <= 0) {
this.crud.notify('不允许新增明细,盘点数量为0!', CRUD.NOTIFICATION_TYPE.INFO)
this.crud.notify('库存数量与盘点数量均为0,该明细不允许保存!', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
if (!row.material_code) {
@@ -312,12 +312,15 @@ export default {
return false
}
for (let i = 0; i < this.form1.tableData.length; i++) {
if (!this.form1.tableData[i].edit) {
const row = this.form1.tableData[i]
if (!row.edit) {
this.crud.notify('尚有未完成编辑的物料明细序号' + (i + 1) + ',请检查!')
return false
}
if (this.form1.tableData[i].fac_qty === '' || this.form1.tableData[i].fac_qty === 0) {
this.crud.notify('盘点数量不能为0序号' + (i + 1) + ',请检查!')
// 盘点数量允许为0(为0时确认盘点后该条组盘库存记录会被删除),但不能为空或负数
const fac_qty = parseFloat(row.fac_qty)
if (row.fac_qty === '' || row.fac_qty === null || row.fac_qty === undefined || isNaN(fac_qty) || fac_qty < 0) {
this.crud.notify('盘点数量不能为空且不能小于0,序号' + (i + 1) + ',请检查!')
return false
}
}