|
|
@ -13,6 +13,7 @@ import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsExportReqVO; |
|
|
|
import com.win.module.eam.controller.itemaccounts.vo.ItemAccountsPageReqVO; |
|
|
|
import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; |
|
|
|
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; |
|
|
|
import com.win.module.eam.dal.dataobject.transaction.TransactionDO; |
|
|
|
import com.win.module.eam.enums.itemAccount.ItemAccountStatusEnum; |
|
|
|
import com.win.module.eam.enums.transaction.TransactionEnum; |
|
|
|
import com.win.module.eam.enums.transactionType.TransactionTypeEnum; |
|
|
@ -20,6 +21,7 @@ import org.apache.ibatis.annotations.Mapper; |
|
|
|
import org.apache.ibatis.annotations.Param; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -38,8 +40,9 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
/** |
|
|
|
* 更新库存余额数量,出库qty是负数 |
|
|
|
*/ |
|
|
|
default Boolean updateItemAccountsQty(ItemAccountsCreateReqVO param, String transactionType, String InventoryAction) { |
|
|
|
default List<TransactionDO> updateItemAccountsQty(ItemAccountsCreateReqVO param, String transactionType, String InventoryAction) { |
|
|
|
int result = 0; |
|
|
|
List<TransactionDO> list = new ArrayList<>(); |
|
|
|
BigDecimal qtyNew = param.getQty();//增减数量
|
|
|
|
if (TransactionTypeEnum.TransactionType_OUT.getCode().equals(transactionType)) {//出库操作
|
|
|
|
if (TransactionEnum.REQUISITION_OUT.getCode().equals(InventoryAction)) {//领用出库优先账外 账内 新到货
|
|
|
@ -68,11 +71,21 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
if (outQty.compareTo(BigDecimal.ZERO) > 0) {//说明账外库存在且数据不为0 需要先把账外库清空
|
|
|
|
outLocation.setQty(outQty); |
|
|
|
result = this.updateById(outLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(outLocation.getQty()); |
|
|
|
transactionDO.setType(outLocation.getType()); |
|
|
|
list.add(transactionDO); |
|
|
|
BigDecimal subtractOutQty = qtyNew.subtract(outQty);//差几个零件
|
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) >= 0) {//账内库存在且大于0足够差额
|
|
|
|
BigDecimal subtractInQty = inQty.subtract(subtractOutQty);//减去之后的数量
|
|
|
|
inLocation.setQty(subtractInQty); |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO1 = new TransactionDO(); |
|
|
|
transactionDO1.setQty(inLocation.getQty()); |
|
|
|
transactionDO1.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO1); |
|
|
|
} |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractOutQty) < 0) {//账内库存在且不足差额
|
|
|
|
inLocation.setQty(inQty); |
|
|
@ -81,7 +94,12 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
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.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO2); |
|
|
|
} else { |
|
|
|
throw exception(COUNT_IS_HAVA); |
|
|
|
} |
|
|
@ -91,6 +109,11 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal subtractNewQty = newQty.subtract(subtractOutQty);//减去之后的数量
|
|
|
|
newLocation.setQty(subtractNewQty); |
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO3 = new TransactionDO(); |
|
|
|
transactionDO3.setQty(newLocation.getQty()); |
|
|
|
transactionDO3.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO3); |
|
|
|
} else { |
|
|
|
throw exception(COUNT_IS_HAVA); |
|
|
|
} |
|
|
@ -101,15 +124,30 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal subtractInQty = inQty.subtract(qtyNew);//减去之后的数量
|
|
|
|
inLocation.setQty(subtractInQty); |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO4 = new TransactionDO(); |
|
|
|
transactionDO4.setQty(inLocation.getQty()); |
|
|
|
transactionDO4.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO4); |
|
|
|
} |
|
|
|
if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(qtyNew) < 0) {//账内库存在且不足差额
|
|
|
|
inLocation.setQty(inQty); |
|
|
|
result = this.updateById(inLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO5 = new TransactionDO(); |
|
|
|
transactionDO5.setQty(inLocation.getQty()); |
|
|
|
transactionDO5.setType(inLocation.getType()); |
|
|
|
list.add(transactionDO5); |
|
|
|
BigDecimal subtractInQty = qtyNew.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 transactionDO6 = new TransactionDO(); |
|
|
|
transactionDO6.setQty(newLocation.getQty()); |
|
|
|
transactionDO6.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO6); |
|
|
|
} else { |
|
|
|
throw exception(COUNT_IS_HAVA); |
|
|
|
} |
|
|
@ -119,6 +157,11 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal subtractNewQty = newQty.subtract(qtyNew);//减去之后的数量
|
|
|
|
newLocation.setQty(subtractNewQty); |
|
|
|
result = this.updateById(newLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO7 = new TransactionDO(); |
|
|
|
transactionDO7.setQty(newLocation.getQty()); |
|
|
|
transactionDO7.setType(newLocation.getType()); |
|
|
|
list.add(transactionDO7); |
|
|
|
} else { |
|
|
|
throw exception(COUNT_IS_HAVA); |
|
|
|
} |
|
|
@ -128,6 +171,11 @@ public interface ItemAccountsMapper extends BaseMapperX<ItemAccountsDO> { |
|
|
|
BigDecimal subtractOutQty = outQty.subtract(qtyNew);//减去之后的数量
|
|
|
|
outLocation.setQty(subtractOutQty); |
|
|
|
result = this.updateById(outLocation); |
|
|
|
//添加库存事务
|
|
|
|
TransactionDO transactionDO8 = new TransactionDO(); |
|
|
|
transactionDO8.setQty(outLocation.getQty()); |
|
|
|
transactionDO8.setType(outLocation.getType()); |
|
|
|
list.add(transactionDO8); |
|
|
|
} |
|
|
|
} else {//非领用出库
|
|
|
|
QueryWrapper<ItemAccountsDO> queryWrapper = new QueryWrapper<>(); |
|
|
@ -141,6 +189,10 @@ 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.setType(itemAccountsDO.getType()); |
|
|
|
list.add(transactionDO); |
|
|
|
} |
|
|
|
} |
|
|
|
if (TransactionTypeEnum.TransactionType_IN.getCode().equals(transactionType)) {//入库操作
|
|
|
@ -152,15 +204,22 @@ 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()); |
|
|
|
list.add(transactionDO); |
|
|
|
} else {//更新
|
|
|
|
BigDecimal qty = itemAccountsDO.getQty(); |
|
|
|
BigDecimal add = qty.add(param.getQty()); |
|
|
|
itemAccountsDO.setQty(add); |
|
|
|
result = updateById(itemAccountsDO); |
|
|
|
TransactionDO transactionDO = new TransactionDO(); |
|
|
|
transactionDO.setQty(itemAccountsDO.getQty()); |
|
|
|
transactionDO.setType(itemAccountsDO.getType()); |
|
|
|
list.add(transactionDO); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return result > 0; |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
default PageResult<ItemAccountsDO> selectPage(ItemAccountsPageReqVO reqVO) { |
|
|
|