|
@@ -26,6 +26,7 @@ import com.dk.mdm.model.pojo.ivt.Outbound;
|
|
|
import com.dk.mdm.model.pojo.ivt.OutboundItem;
|
|
import com.dk.mdm.model.pojo.ivt.OutboundItem;
|
|
|
import com.dk.mdm.model.pojo.pur.Purchase;
|
|
import com.dk.mdm.model.pojo.pur.Purchase;
|
|
|
import com.dk.mdm.model.pojo.pur.PurchaseItem;
|
|
import com.dk.mdm.model.pojo.pur.PurchaseItem;
|
|
|
|
|
+import com.dk.mdm.model.pojo.sale.Order;
|
|
|
import com.dk.mdm.model.pojo.sale.OrderItem;
|
|
import com.dk.mdm.model.pojo.sale.OrderItem;
|
|
|
import com.dk.mdm.model.query.ivt.InboundItemQuery;
|
|
import com.dk.mdm.model.query.ivt.InboundItemQuery;
|
|
|
import com.dk.mdm.model.query.ivt.InboundQuery;
|
|
import com.dk.mdm.model.query.ivt.InboundQuery;
|
|
@@ -35,6 +36,7 @@ import com.dk.mdm.model.response.ivt.*;
|
|
|
import com.dk.mdm.model.response.pur.PurchaseItemResponse;
|
|
import com.dk.mdm.model.response.pur.PurchaseItemResponse;
|
|
|
import com.dk.mdm.model.response.pur.PurchaseResponse;
|
|
import com.dk.mdm.model.response.pur.PurchaseResponse;
|
|
|
import com.dk.mdm.model.response.sale.OrderItemResponse;
|
|
import com.dk.mdm.model.response.sale.OrderItemResponse;
|
|
|
|
|
+import com.dk.mdm.model.response.sale.OrderResponse;
|
|
|
import com.dk.mdm.model.vo.ivt.InboundItemVO;
|
|
import com.dk.mdm.model.vo.ivt.InboundItemVO;
|
|
|
import com.dk.mdm.model.vo.ivt.InboundVO;
|
|
import com.dk.mdm.model.vo.ivt.InboundVO;
|
|
|
import com.dk.mdm.model.vo.ivt.OutboundItemVO;
|
|
import com.dk.mdm.model.vo.ivt.OutboundItemVO;
|
|
@@ -169,10 +171,11 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//查询库存批次最近一条入库价
|
|
//查询库存批次最近一条入库价
|
|
|
InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
|
|
InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
|
|
|
//todo 2024年7月5日15:57:01 priceOut和outingAmt 前台传 z确认修改
|
|
//todo 2024年7月5日15:57:01 priceOut和outingAmt 前台传 z确认修改
|
|
|
-// inboundItemVO.setPriceInto(inboundItemResponse != null ? inboundItemResponse.getPriceInto() : BigDecimal.ZERO);
|
|
|
|
|
-// inboundItemVO.setIntoingAmt(inboundItemResponse != null ? inboundItemResponse.getPriceInto().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
|
|
|
|
|
+ //todo 2024年7月9日08:52:55 入库价和入库价总和后台计算 z确认修改
|
|
|
inboundItemVO.setCostPrice(inboundItemResponse != null ? inboundItemResponse.getCostPrice() : BigDecimal.ZERO);
|
|
inboundItemVO.setCostPrice(inboundItemResponse != null ? inboundItemResponse.getCostPrice() : BigDecimal.ZERO);
|
|
|
inboundItemVO.setCostAmt(inboundItemResponse != null ? inboundItemResponse.getCostPrice().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
inboundItemVO.setCostAmt(inboundItemResponse != null ? inboundItemResponse.getCostPrice().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
|
|
|
+ inboundItemVO.setPriceInto(inboundItemResponse != null ? inboundItemResponse.getCostPrice() : BigDecimal.ZERO);
|
|
|
|
|
+ inboundItemVO.setIntoingAmt(inboundItemResponse != null ? inboundItemResponse.getPriceInto().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (priceIntoFlag) {
|
|
if (priceIntoFlag) {
|
|
@@ -228,37 +231,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 采购总单
|
|
//region 采购总单
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
|
|
- Purchase purchaseUpdate = new Purchase();
|
|
|
|
|
- purchaseUpdate.setPurId(inboundVO.getFromId());
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
- //已入库
|
|
|
|
|
- if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
|
|
- purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
|
|
- purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
|
|
- purchaseUpdate.setIntoQty(inboundVO.getIntoQty());
|
|
|
|
|
- purchaseUpdate.setIntoAmt(inboundVO.getIntoAmt());
|
|
|
|
|
- }
|
|
|
|
|
- //入库中
|
|
|
|
|
- else {
|
|
|
|
|
- purchaseUpdate.setIntoingQty(inboundVO.getIntoingQty());
|
|
|
|
|
- purchaseUpdate.setIntoingAmt(inboundVO.getIntoingAmt());
|
|
|
|
|
- purchaseUpdate.setIntoQty(BigDecimal.ZERO);
|
|
|
|
|
- purchaseUpdate.setIntoAmt(BigDecimal.ZERO);
|
|
|
|
|
- }
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchaseUpdate.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchaseUpdate.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchaseUpdate.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchaseUpdate);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.insertOrderMessageByEdit(inboundVO,inboundVO.getItemList());
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 明细
|
|
//region 明细
|
|
@@ -281,8 +254,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
|
|
;
|
|
;
|
|
|
} else {
|
|
} else {
|
|
|
inboundItemVO
|
|
inboundItemVO
|
|
@@ -350,6 +321,58 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @desc : 新建采购入库修改采购订单信息
|
|
|
|
|
+ * @date : 2024/7/6 15:15
|
|
|
|
|
+ * @author : 寇珊珊
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public void insertOrderMessageByEdit(InboundVO inboundVO , List<InboundItemVO> itemList){
|
|
|
|
|
+ //入库明细汇总
|
|
|
|
|
+ Map<String, List<InboundItemVO>> purchaseIntoItemVOListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
|
|
|
|
|
+ //入库明细汇总循环
|
|
|
|
|
+ for (String fromId : purchaseIntoItemVOListMap.keySet()) {
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 入库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoingQty(BigDecimal.ZERO);
|
|
|
|
|
+ purchase.setIntoingAmt(BigDecimal.ZERO);
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty);
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt);
|
|
|
|
|
+ }
|
|
|
|
|
+ //出库中
|
|
|
|
|
+ else {
|
|
|
|
|
+ purchase.setIntoingQty(purchaseSumQty);
|
|
|
|
|
+ purchase.setIntoingAmt(purchaseSumAmt);
|
|
|
|
|
+ purchase.setIntoQty(BigDecimal.ZERO);
|
|
|
|
|
+ purchase.setIntoAmt(BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* @desc : 采购入库编辑
|
|
* @desc : 采购入库编辑
|
|
|
* @date : 2024/3/25 16:25
|
|
* @date : 2024/3/25 16:25
|
|
|
* @author : 寇珊珊
|
|
* @author : 寇珊珊
|
|
@@ -391,6 +414,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
|
|
|
|
|
//region 已入库编辑
|
|
//region 已入库编辑
|
|
|
if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+
|
|
|
//region 退账
|
|
//region 退账
|
|
|
if (inboundVO.getReceivableId() != null) {
|
|
if (inboundVO.getReceivableId() != null) {
|
|
|
accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
@@ -403,9 +427,14 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//根据id查询
|
|
//根据id查询
|
|
|
InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
|
|
|
|
|
- //region 编辑明细 赋值
|
|
|
|
|
|
|
+ //region 编辑明细
|
|
|
if (inboundItemVO.getItemId() != null) {
|
|
if (inboundItemVO.getItemId() != null) {
|
|
|
|
|
|
|
|
|
|
+ //region 反写订单总单 数据需要 把查出来的已入库数量用别的变量存起来
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoQty(inboundItemResponse.getIntoQty());
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoAmt(inboundItemResponse.getIntoAmt());
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
//region 将库存需要的参数赋值
|
|
//region 将库存需要的参数赋值
|
|
|
inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
@@ -422,8 +451,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
inboundItem.setItemId(inboundItemVO.getItemId());
|
|
inboundItem.setItemId(inboundItemVO.getItemId());
|
|
|
inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
|
|
inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
|
|
|
inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
|
- inboundItem.setCostPrice(inboundItemVO.getPriceInto());
|
|
|
|
|
- inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
//修改
|
|
//修改
|
|
|
inboundItemMapper.update(inboundItem,
|
|
inboundItemMapper.update(inboundItem,
|
|
|
new UpdateWrapper<InboundItem>().lambda()
|
|
new UpdateWrapper<InboundItem>().lambda()
|
|
@@ -439,8 +466,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
|
|
- .setCostAmt(inboundItemVO.getOutQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
|
|
;
|
|
;
|
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
//入库状态
|
|
//入库状态
|
|
@@ -542,28 +567,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改销售总单
|
|
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundVO.getFromId());
|
|
|
|
|
- purchase.setIntoQty(inboundResponse.getIntoQty().negate().add(sumQty).subtract(delIntoQty));
|
|
|
|
|
- purchase.setIntoAmt(inboundResponse.getIntoAmt().negate().add(sumAmt).subtract(delIntoAmt));
|
|
|
|
|
- purchase.setIntoingQty(delIntoQty);
|
|
|
|
|
- purchase.setIntoingAmt(delIntoAmt);
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- //endregion
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //region 修改采购订单总单
|
|
|
|
|
+ this.updateOrderMessageByEdit(inboundResponse, inboundVO.getItemList(), inboundVO.getDeleteItemList());
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 入账
|
|
//region 入账
|
|
@@ -578,14 +583,13 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
map.put("delIntoDetail", inboundVO.getDeleteItemList());
|
|
map.put("delIntoDetail", inboundVO.getDeleteItemList());
|
|
|
inventoryService.operatingInventoryInformation(map);
|
|
inventoryService.operatingInventoryInformation(map);
|
|
|
//endregion
|
|
//endregion
|
|
|
- } else {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.FLG_HANDLE_SETTING_NOT_ENABLED_INTO.getMessage());
|
|
|
|
|
}
|
|
}
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 入库中编辑
|
|
//region 入库中编辑
|
|
|
if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundResponse.getIntoStatus()) ||
|
|
if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundResponse.getIntoStatus()) ||
|
|
|
Constant.IntoStatus.DAIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
Constant.IntoStatus.DAIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+
|
|
|
//region 修改明细
|
|
//region 修改明细
|
|
|
List<InboundItemVO> itemList = inboundVO.getItemList();
|
|
List<InboundItemVO> itemList = inboundVO.getItemList();
|
|
|
for (InboundItemVO inboundItemVO : itemList) {
|
|
for (InboundItemVO inboundItemVO : itemList) {
|
|
@@ -595,6 +599,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
|
|
|
|
|
//region 编辑明细
|
|
//region 编辑明细
|
|
|
if (inboundItemVO.getItemId() != null) {
|
|
if (inboundItemVO.getItemId() != null) {
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单总单 数据需要 把查出来的入库中数量用别的变量存起来
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoingQty(inboundItemResponse.getIntoingQty());
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoingAmt(inboundItemResponse.getIntoingAmt());
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
InboundItem inboundItem = new InboundItem();
|
|
InboundItem inboundItem = new InboundItem();
|
|
|
inboundItem.setItemId(inboundItemVO.getItemId());
|
|
inboundItem.setItemId(inboundItemVO.getItemId());
|
|
|
inboundItem.setIntoingQty(inboundItemVO.getIntoingQty());
|
|
inboundItem.setIntoingQty(inboundItemVO.getIntoingQty());
|
|
@@ -612,8 +622,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
inboundItemVO
|
|
inboundItemVO
|
|
|
.setIntoQty(BigDecimal.ZERO)
|
|
.setIntoQty(BigDecimal.ZERO)
|
|
|
.setIntoAmt(BigDecimal.ZERO)
|
|
.setIntoAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
|
|
- .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
|
|
;
|
|
;
|
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
//入库状态
|
|
//入库状态
|
|
@@ -702,28 +710,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改采购总单
|
|
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundVO.getFromId());
|
|
|
|
|
- purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().add(sumQty).subtract(delIntoQty));
|
|
|
|
|
- purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().add(sumAmt).subtract(delIntoAmt));
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //region 修改采购订单总单
|
|
|
|
|
+ this.updateOrderMessageByEdit(inboundResponse, inboundVO.getItemList(), inboundVO.getDeleteItemList());
|
|
|
//endregion
|
|
//endregion
|
|
|
- } else {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.FLG_HANDLE_SETTING_NOT_ENABLED_INTO.getMessage());
|
|
|
|
|
}
|
|
}
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
@@ -734,6 +723,162 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @desc : 采购入库编辑修改订单信息
|
|
|
|
|
+ * @date : 2024/7/8 9:12
|
|
|
|
|
+ * @author : 寇珊珊
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public void updateOrderMessageByEdit(InboundResponse inboundResponse, List<InboundItemVO> itemList, List<InboundItemVO> deleteItemList) {
|
|
|
|
|
+ //入库明细汇总
|
|
|
|
|
+ Map<String, List<InboundItemVO>> purchaseIntoItemVOListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
|
|
|
|
|
+ //入库明细删除汇总
|
|
|
|
|
+ Map<String, List<InboundItemVO>> delPurchaseIntoItemVOListMap = deleteItemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
|
|
|
|
|
+ //人库明细汇总循环
|
|
|
|
|
+ for (String fromId : purchaseIntoItemVOListMap.keySet()) {
|
|
|
|
|
+ //有需要删除的修改数据
|
|
|
|
|
+ if(delPurchaseIntoItemVOListMap!=null && delPurchaseIntoItemVOListMap.keySet().size()>0){
|
|
|
|
|
+ //出库明细删除汇总循环
|
|
|
|
|
+ for (String delFromId : delPurchaseIntoItemVOListMap.keySet()) {
|
|
|
|
|
+ //新建入库明细来源Id = 删除入库明细来源Id
|
|
|
|
|
+ if (fromId.equals(delFromId)) {
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
|
|
+ BigDecimal updatePurchaseIntoQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoAmt = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingAmt = BigDecimal.ZERO;
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ updatePurchaseIntoQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else {
|
|
|
|
|
+ updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取删除分组后的明细
|
|
|
|
|
+ List<InboundItemVO> delPurchaseIntoItemVOListGroup = delPurchaseIntoItemVOListMap.get(delFromId);
|
|
|
|
|
+ BigDecimal purchaseDelOutQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal purchaseDelOutAmt = BigDecimal.ZERO;
|
|
|
|
|
+ //已出库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchaseDelOutQty = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ purchaseDelOutAmt = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //出库中
|
|
|
|
|
+ else if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchaseDelOutQty = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ purchaseDelOutAmt = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty.subtract(updatePurchaseIntoQty).subtract(purchaseDelOutQty));
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt.subtract(updatePurchaseIntoAmt).subtract(purchaseDelOutAmt));
|
|
|
|
|
+ purchase.setIntoingQty(purchaseDelOutQty);
|
|
|
|
|
+ purchase.setIntoingAmt(purchaseDelOutAmt);
|
|
|
|
|
+ purchase.setUpdateIntoingMessageFlag(true);
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoingQty(purchaseSumQty.subtract(updatePurchaseIntoingQty).subtract(purchaseDelOutQty));
|
|
|
|
|
+ purchase.setIntoingAmt(purchaseSumAmt.subtract(updatePurchaseIntoingAmt).subtract(purchaseDelOutAmt));
|
|
|
|
|
+ purchase.setUpdateIntoingMessageFlag(true);
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //没有需要删除的修改数据
|
|
|
|
|
+ else{
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 出库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //分组后的明细 原出库数量和金额总和
|
|
|
|
|
+ BigDecimal updatePurchaseIntoQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoAmt = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingAmt = BigDecimal.ZERO;
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ updatePurchaseIntoQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoQty() != null).map(InboundItemVO::getUpdatePurchaseIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else {
|
|
|
|
|
+ updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ //已出库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty.subtract(updatePurchaseIntoQty));
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt.subtract(updatePurchaseIntoAmt));
|
|
|
|
|
+ purchase.setUpdateIntoMessageFlag(true);
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoingQty(updatePurchaseIntoingQty.negate());
|
|
|
|
|
+ purchase.setIntoingAmt(updatePurchaseIntoingAmt.negate());
|
|
|
|
|
+ purchase.setUpdateIntoingMessageFlag(true);
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* @desc : 采购入库作废
|
|
* @desc : 采购入库作废
|
|
|
* @date : 2024/3/26 9:24
|
|
* @date : 2024/3/26 9:24
|
|
|
* @author : 寇珊珊
|
|
* @author : 寇珊珊
|
|
@@ -810,25 +955,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改销售总单
|
|
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
|
|
- purchase.setIntoQty(inboundResponse.getIntoQty().negate());
|
|
|
|
|
- purchase.setIntoAmt(inboundResponse.getIntoAmt().negate());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty(),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //region 修改采购总单
|
|
|
|
|
+ this.updateOrderMessageByRepeal(inboundResponse, inboundItemResponseList);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 入账
|
|
//region 入账
|
|
@@ -897,26 +1025,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改销售总单
|
|
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
|
|
- purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
|
|
|
|
|
- purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //region 修改采购总单
|
|
|
|
|
+ this.updateOrderMessageByRepeal(inboundResponse, inboundItemResponseList);
|
|
|
//endregion
|
|
//endregion
|
|
|
}
|
|
}
|
|
|
//endregion
|
|
//endregion
|
|
@@ -925,11 +1035,75 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @desc : 采购入库办理
|
|
|
|
|
- * @date : 2024/3/7 15:47
|
|
|
|
|
|
|
+ * @desc : 采购入库作废修改采购订单信息
|
|
|
|
|
+ * @date : 2024/7/6 15:27
|
|
|
* @author : 寇珊珊
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public void updateOrderMessageByRepeal(InboundResponse inboundResponse, List<InboundItemResponse> itemList) {
|
|
|
|
|
+ //出库明细汇总
|
|
|
|
|
+ Map<String, List<InboundItemResponse>> purchaseIntoItemListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemResponse::getFromId));
|
|
|
|
|
+ //出库明细汇总循环
|
|
|
|
|
+ for (String fromId : purchaseIntoItemListMap.keySet()) {
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ //分组后的明细 原入库数量和金额总和
|
|
|
|
|
+ List<InboundItemResponse> purchaseIntoItemListGroup = purchaseIntoItemListMap.get(fromId);
|
|
|
|
|
+ BigDecimal updatePurchaseIntoQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoAmt = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingQty = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingAmt = BigDecimal.ZERO;
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
|
|
|
|
|
+ updatePurchaseIntoQty = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoAmt = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getOutQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else {
|
|
|
|
|
+ updatePurchaseIntoingQty = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ updatePurchaseIntoingAmt = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ //已入库
|
|
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(purchaseResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoQty(updatePurchaseIntoQty.negate());
|
|
|
|
|
+ purchase.setIntoAmt(updatePurchaseIntoAmt.negate());
|
|
|
|
|
+ //入库转态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty(),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //入库中
|
|
|
|
|
+ else if (Constant.IntoStatus.RUKUZHONG.getName().equals(purchaseResponse.getIntoStatus())) {
|
|
|
|
|
+ purchase.setIntoingQty(updatePurchaseIntoingQty.negate());
|
|
|
|
|
+ purchase.setIntoingAmt(updatePurchaseIntoingAmt.negate());
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc : 采购入库办理
|
|
|
|
|
+ * @date : 2024/3/7 15:47
|
|
|
|
|
+ * @author : 寇珊珊
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
|
|
public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
|
|
|
|
|
|
|
|
//region 根据id查询 此条入库单的数据还未更改前的数据
|
|
//region 根据id查询 此条入库单的数据还未更改前的数据
|
|
@@ -950,24 +1124,28 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
|
|
|
|
|
- //入库明细根据id查询
|
|
|
|
|
- InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
|
|
- //region 校验数量是否超出
|
|
|
|
|
- if (inboundItemVO.getIntoingQty().compareTo(inboundItemResponse.getIntoingQty()) > 0) {
|
|
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getCode(),
|
|
|
|
|
- ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
//region 编辑明细
|
|
//region 编辑明细
|
|
|
if (inboundItemVO.getItemId() != null) {
|
|
if (inboundItemVO.getItemId() != null) {
|
|
|
|
|
+ //入库明细根据id查询
|
|
|
|
|
+ InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
|
|
+
|
|
|
|
|
+ //region 校验数量是否超出
|
|
|
|
|
+ if (inboundItemVO.getIntoingQty().compareTo(inboundItemResponse.getIntoingQty()) > 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getCode(),
|
|
|
|
|
+ ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单总单 数据需要 把查出来的出库中数量用别的变量存起来
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoingQty(inboundItemResponse.getIntoingQty());
|
|
|
|
|
+ inboundItemVO.setUpdatePurchaseIntoingAmt(inboundItemResponse.getIntoingAmt());
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
inboundItemVO
|
|
inboundItemVO
|
|
|
.setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
.setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
|
.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
|
|
;
|
|
;
|
|
|
//入库状态
|
|
//入库状态
|
|
|
String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
@@ -999,8 +1177,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
.setIntoQty(inboundItemVO.getIntoingQty())
|
|
.setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
.setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
.setIntoId(inboundVO.getIntoId())
|
|
.setIntoId(inboundVO.getIntoId())
|
|
|
- .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
|
|
- .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
|
|
.setIntoType(Constant.IntoType.SALE.getName())
|
|
.setIntoType(Constant.IntoType.SALE.getName())
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
@@ -1120,27 +1296,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 修改采购订单
|
|
//region 修改采购订单
|
|
|
- if (inboundVO.getFromId() != null) {
|
|
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundVO.getFromId());
|
|
|
|
|
- purchase.setIntoQty(sumIntoQty.subtract(delIntoQty));
|
|
|
|
|
- purchase.setIntoAmt(sumIntoAmt.subtract(delIntoAmt));
|
|
|
|
|
- purchase.setIntoingQty((inboundResponse.getIntoingQty().add(delIntoingQty)).negate());
|
|
|
|
|
- purchase.setIntoingAmt((inboundResponse.getIntoingAmt().add(delIntoingAmt)).negate());
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(purIntoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.updateOrderMessageByHandle(inboundVO.getItemList(),inboundVO.getDeleteItemList());
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 入账
|
|
//region 入账
|
|
@@ -1158,6 +1314,102 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @desc : 采购入库办理修改采购订单信息
|
|
|
|
|
+ * @date : 2024/7/8 14:03
|
|
|
|
|
+ * @author : 寇珊珊
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public void updateOrderMessageByHandle(List<InboundItemVO> itemList, List<InboundItemVO> deleteItemList) {
|
|
|
|
|
+ //出库明细汇总
|
|
|
|
|
+ Map<String, List<InboundItemVO>> purchaseIntoItemVOListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
|
|
|
|
|
+ //出库明细删除汇总
|
|
|
|
|
+ Map<String, List<InboundItemVO>> delPurchaseIntoItemVOListMap = deleteItemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
|
|
|
|
|
+ //出库明细汇总循环g
|
|
|
|
|
+ for (String fromId : purchaseIntoItemVOListMap.keySet()) {
|
|
|
|
|
+ //有需要删除的办理数据
|
|
|
|
|
+ if (delPurchaseIntoItemVOListMap != null && delPurchaseIntoItemVOListMap.keySet().size() > 0) {
|
|
|
|
|
+ //入库明细删除汇总循环
|
|
|
|
|
+ for (String delFromId : delPurchaseIntoItemVOListMap.keySet()) {
|
|
|
|
|
+ //新建入库明细来源Id = 删除入库明细来源Id
|
|
|
|
|
+ if (fromId.equals(delFromId)) {
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 入库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //分组后的明细 原入库数量和金额总和
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取删除分组后的明细
|
|
|
|
|
+ List<InboundItemVO> delPurchaseIntoItemVOListGroup = delPurchaseIntoItemVOListMap.get(delFromId);
|
|
|
|
|
+ BigDecimal purchaseDelIntoingQty = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseDelIntoingAmt = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseDelIntoQty = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseDelIntoAmt = delPurchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty.subtract(purchaseDelIntoQty));
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt.subtract(purchaseDelIntoAmt));
|
|
|
|
|
+ purchase.setIntoingQty((updatePurchaseIntoingQty.add(purchaseDelIntoingQty)).negate());
|
|
|
|
|
+ purchase.setIntoingAmt((updatePurchaseIntoingAmt.add(purchaseDelIntoingAmt)).negate());
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(purIntoStatus);
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //没有需要删除的办理数据
|
|
|
|
|
+ else {
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 入库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //分组后的明细 原入库数量和金额总和
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty);
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt);
|
|
|
|
|
+ purchase.setIntoingAmt(updatePurchaseIntoingQty.negate());
|
|
|
|
|
+ purchase.setIntoingQty(updatePurchaseIntoingAmt.negate());
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(purIntoStatus);
|
|
|
|
|
+ //修改
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* @desc : 采购入库撤销
|
|
* @desc : 采购入库撤销
|
|
|
* @date : 2024/3/7 17:06
|
|
* @date : 2024/3/7 17:06
|
|
|
* @author : 寇珊珊
|
|
* @author : 寇珊珊
|
|
@@ -1168,6 +1420,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
+ //region 根据总单id查明细
|
|
|
|
|
+ List<InboundItemResponse> inboundItemResponseList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inboundResponse.getIntoId()));
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
//region 退账
|
|
//region 退账
|
|
|
if (inboundResponse.getReceivableId() != null) {
|
|
if (inboundResponse.getReceivableId() != null) {
|
|
|
accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
@@ -1175,26 +1431,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 修改订单数据信息
|
|
//region 修改订单数据信息
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
|
|
- //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
|
|
- purchase.setIntoQty(inboundResponse.getIntoQty().negate());
|
|
|
|
|
- purchase.setIntoAmt(inboundResponse.getIntoAmt().negate());
|
|
|
|
|
- purchase.setIntoingQty(inboundResponse.getIntoQty());
|
|
|
|
|
- purchase.setIntoingAmt(inboundResponse.getIntoAmt());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.updateOrderMessageByCancel(inboundItemResponseList);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 修改总单数据信息
|
|
//region 修改总单数据信息
|
|
@@ -1214,9 +1451,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 明细数据
|
|
//region 明细数据
|
|
|
- //根据总单id查明细
|
|
|
|
|
- List<InboundItemResponse> inboundItemResponseList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
|
|
|
|
|
for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
|
|
for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
|
|
|
|
|
+
|
|
|
//region 修改采购明细数据信息
|
|
//region 修改采购明细数据信息
|
|
|
if (inboundItemResponse.getFromItemId() != null) {
|
|
if (inboundItemResponse.getFromItemId() != null) {
|
|
|
//根据id查询
|
|
//根据id查询
|
|
@@ -1282,7 +1518,47 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
return ResponseResultUtil.success();
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*****************************************查库存*****************************************/
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc : 采购入库撤销修改采购订单信息
|
|
|
|
|
+ * @date : 2024/7/8 16:50
|
|
|
|
|
+ * @author : 寇珊珊
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public void updateOrderMessageByCancel(List<InboundItemResponse> itemList) {
|
|
|
|
|
+ //出库明细汇总
|
|
|
|
|
+ Map<String, List<InboundItemResponse>> purchaseIntoItemListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemResponse::getFromId));
|
|
|
|
|
+ //出库明细汇总循环
|
|
|
|
|
+ for (String fromId : purchaseIntoItemListMap.keySet()) {
|
|
|
|
|
+
|
|
|
|
|
+ //region 提取新建分组后的明细
|
|
|
|
|
+ List<InboundItemResponse> purchaseIntoItemListGroup = purchaseIntoItemListMap.get(fromId);
|
|
|
|
|
+ //分组后的明细 入库数量和金额总和
|
|
|
|
|
+ BigDecimal purchaseSumQty = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ BigDecimal purchaseSumAmt = purchaseIntoItemListGroup.stream().map(InboundItemResponse::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
+ //endregion
|
|
|
|
|
+
|
|
|
|
|
+ //region 反写订单数据
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ //根据id查询
|
|
|
|
|
+ PurchaseResponse purchaseResponse = purchaseMapper.selectById(fromId);
|
|
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
|
|
+ purchase.setPurId(fromId);
|
|
|
|
|
+ purchase.setIntoingQty(purchaseSumQty);
|
|
|
|
|
+ purchase.setIntoingAmt(purchaseSumAmt);
|
|
|
|
|
+ purchase.setIntoQty(purchaseSumQty.negate());
|
|
|
|
|
+ purchase.setIntoAmt(purchaseSumAmt.negate());
|
|
|
|
|
+ //入库状态
|
|
|
|
|
+ String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
+ purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
+ purchase.setIntoStatus(intoStatus);
|
|
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
+ //数量超出
|
|
|
|
|
+ if (countRow == 0) {
|
|
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ //endregion
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @desc : 校验库存是否存在和库存量是否足够本次退货作废
|
|
* @desc : 校验库存是否存在和库存量是否足够本次退货作废
|
|
@@ -1317,7 +1593,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /*****************************************先判断库存*****************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @desc : 一键作废
|
|
* @desc : 一键作废
|
|
@@ -1403,25 +1678,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改销售总单
|
|
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
|
|
- purchase.setIntoQty(inboundResponse.getIntoQty().negate());
|
|
|
|
|
- purchase.setIntoAmt(inboundResponse.getIntoAmt().negate());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty(),
|
|
|
|
|
- purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //region 修改采购总单
|
|
|
|
|
+ this.updateOrderMessageByRepeal(inboundResponse, inboundItemResponseList);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
//region 入账
|
|
//region 入账
|
|
@@ -1491,26 +1749,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
);
|
|
);
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
- //region 修改销售总单
|
|
|
|
|
- if (inboundResponse.getFromId() != null) {
|
|
|
|
|
- //根据id查询
|
|
|
|
|
- PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
|
|
|
|
|
- Purchase purchase = new Purchase();
|
|
|
|
|
- purchase.setPurId(inboundResponse.getFromId());
|
|
|
|
|
- purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
|
|
|
|
|
- purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
|
|
|
|
|
- //入库状态
|
|
|
|
|
- String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
|
|
|
|
|
- purchaseResponse.getIntoQty(), purchaseResponse.getSumQuantity());
|
|
|
|
|
- purchase.setIntoStatus(intoStatus);
|
|
|
|
|
- //修改
|
|
|
|
|
- int countRow = purchaseMapper.updateById(purchase);
|
|
|
|
|
- //数量超出
|
|
|
|
|
- if (countRow == 0) {
|
|
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //region 修改采购总单
|
|
|
|
|
+ this.updateOrderMessageByRepeal(inboundResponse, inboundItemResponseList);
|
|
|
//endregion
|
|
//endregion
|
|
|
}
|
|
}
|
|
|
//endregion
|
|
//endregion
|
|
@@ -1519,8 +1759,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
return ResponseResultUtil.success();
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @desc : 入库状态通用(目前本页面)
|
|
* @desc : 入库状态通用(目前本页面)
|
|
|
* @date : 2024/3/9 8:59
|
|
* @date : 2024/3/9 8:59
|
|
@@ -1557,8 +1795,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty, BigDecimal sumQty) {
|
|
public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty, BigDecimal sumQty) {
|
|
|
//入库状态
|
|
//入库状态
|
|
|
String intoStatus = null;
|
|
String intoStatus = null;
|
|
|
- //入库中+已入库 小于 总数 并且 入库中数量 等于订单总数量
|
|
|
|
|
- if (intoingQty.compareTo(sumQty) <= 0 && intoingQty.add(intoQty).compareTo(sumQty) <= 0) {
|
|
|
|
|
|
|
+ //入库中小于等于总数,已入库小于总数,并且入库中+已入库大于0
|
|
|
|
|
+ if (intoingQty.compareTo(sumQty) <= 0 && intoQty.compareTo(sumQty) < 0 && intoingQty.add(intoQty).compareTo(BigDecimal.ZERO) > 0) {
|
|
|
//入库中
|
|
//入库中
|
|
|
intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
|
|
|
}
|
|
}
|
|
@@ -1567,7 +1805,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//待入库
|
|
//待入库
|
|
|
intoStatus = Constant.IntoStatus.DAIRUKU.getName();
|
|
intoStatus = Constant.IntoStatus.DAIRUKU.getName();
|
|
|
}
|
|
}
|
|
|
- //入库中+已入库 等于 总数 并且 入库中数量 小于等于订单总数量
|
|
|
|
|
|
|
+ //入库中+已入库 等于 总数 并且 入库中数量小于等于订单总数量
|
|
|
else if (intoingQty.compareTo(sumQty) < 0 && intoingQty.add(intoQty).compareTo(sumQty) == 0) {
|
|
else if (intoingQty.compareTo(sumQty) < 0 && intoingQty.add(intoQty).compareTo(sumQty) == 0) {
|
|
|
//已入库
|
|
//已入库
|
|
|
intoStatus = Constant.IntoStatus.YIRUKU.getName();
|
|
intoStatus = Constant.IntoStatus.YIRUKU.getName();
|