|
|
@ -69,11 +69,11 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
ItemAccountsDO newLocation = getByLocationAndType(param.getLocationNumber(), ItemAccountStatusEnum.NEW.getCode());//账内库库存
|
|
|
|
newQty = newLocation == null ? BigDecimal.ZERO : newLocation.getQty(); |
|
|
|
if (outQty.compareTo(BigDecimal.ZERO) > 0) {//说明账外库存在且数据不为0 需要先把账外库清空
|
|
|
|
outLocation.setQty(outQty); |
|
|
|
outLocation.setQty(BigDecimal.ZERO); |
|
|
|
result = this.updateById(outLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(outLocation.getQty()); |
|
|
|
transactionDO.setQty(outQty); |
|
|
|
transactionDO.setType(outLocation.getType()); |
|
|
|
list.add(transactionDO); |
|
|
|
BigDecimal subtractOutQty = qtyNew.subtract(outQty);//差几个零件
|
|
|
@ -83,21 +83,26 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO1 = new TransactionDO(); |
|
|
|
transactionDO1.setQty(inLocation.getQty()); |
|
|
|
transactionDO1.setQty(subtractOutQty); |
|
|
|
transactionDO1.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO1); |
|
|
|
} |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额
|
|
|
|
inLocation.setQty(inQty); |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额需要清空账内
|
|
|
|
inLocation.setQty(BigDecimal.ZERO); |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO0 = new TransactionDO(); |
|
|
|
transactionDO0.setQty(inQty); |
|
|
|
transactionDO0.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO0); |
|
|
|
BigDecimal subtractInQty = subtractOutQty.subtract(inQty);//减去之后的数量
|
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractInQty) >= 0) {//新到货存在且足够差额
|
|
|
|
BigDecimal subtractNewQty = newQty.subtract(subtractInQty);//减去之后的数量
|
|
|
|
newLocation.setQty(subtractNewQty); |
|
|
|
//添加库存事务
|
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO2 = new TransactionDO(); |
|
|
|
transactionDO2.setQty(newLocation.getQty()); |
|
|
|
transactionDO2.setQty(subtractInQty); |
|
|
|
transactionDO2.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO2); |
|
|
|
} else { |
|
|
@ -111,7 +116,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO3 = new TransactionDO(); |
|
|
|
transactionDO3.setQty(newLocation.getQty()); |
|
|
|
transactionDO3.setQty(subtractOutQty); |
|
|
|
transactionDO3.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO3); |
|
|
|
} else { |
|
|
@ -126,16 +131,16 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO4 = new TransactionDO(); |
|
|
|
transactionDO4.setQty(inLocation.getQty()); |
|
|
|
transactionDO4.setQty(qtyNew); |
|
|
|
transactionDO4.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO4); |
|
|
|
} |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额
|
|
|
|
inLocation.setQty(inQty); |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额清空
|
|
|
|
inLocation.setQty(BigDecimal.ZERO); |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO5 = new TransactionDO(); |
|
|
|
transactionDO5.setQty(inLocation.getQty()); |
|
|
|
transactionDO5.setQty(inQty); |
|
|
|
transactionDO5.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO5); |
|
|
|
BigDecimal subtractInQty = qtyNew.subtract(inQty);//减去之后的数量
|
|
|
@ -145,7 +150,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO6 = new TransactionDO(); |
|
|
|
transactionDO6.setQty(newLocation.getQty()); |
|
|
|
transactionDO6.setQty(subtractInQty); |
|
|
|
transactionDO6.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO6); |
|
|
|
} else { |
|
|
@ -159,7 +164,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO7 = new TransactionDO(); |
|
|
|
transactionDO7.setQty(newLocation.getQty()); |
|
|
|
transactionDO7.setQty(qtyNew); |
|
|
|
transactionDO7.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO7); |
|
|
|
} else { |
|
|
@ -173,7 +178,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
result = this.updateById(outLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO8 = new TransactionDO(); |
|
|
|
transactionDO8.setQty(outLocation.getQty()); |
|
|
|
transactionDO8.setQty(qtyNew); |
|
|
|
transactionDO8.setType(outLocation.getType()); |
|
|
|
list.add(transactionDO8); |
|
|
|
} |
|
|
@ -189,8 +194,9 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal subtractNewQty = itemAccountsDO.getQty().subtract(qtyNew);//减去之后的数量
|
|
|
|
itemAccountsDO.setQty(subtractNewQty); |
|
|
|
result = this.updateById(itemAccountsDO); |
|
|
|
//事务记录
|
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(subtractNewQty); |
|
|
|
transactionDO.setQty(qtyNew); |
|
|
|
transactionDO.setType(itemAccountsDO.getType()); |
|
|
|
list.add(transactionDO); |
|
|
|
} |
|
|
@ -204,6 +210,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
if (itemAccountsDO == null) {//不存在新增
|
|
|
|
itemAccountsDO = ItemAccountsConvert.INSTANCE.convert(param); |
|
|
|
result = this.insert(itemAccountsDO); |
|
|
|
//库存事务
|
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(itemAccountsDO.getQty()); |
|
|
|
transactionDO.setType(itemAccountsDO.getType()); |
|
|
@ -212,6 +219,7 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal qty = itemAccountsDO.getQty(); |
|
|
|
BigDecimal add = qty.add(param.getQty()); |
|
|
|
itemAccountsDO.setQty(add); |
|
|
|
//库存事务
|
|
|
|
result = updateById(itemAccountsDO); |
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(itemAccountsDO.getQty()); |
|
|
|