|
|
@@ -7,6 +7,7 @@ import com.dk.common.infrastructure.constant.Constant;
|
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.common.model.pojo.PageList;
|
|
|
+import com.dk.common.model.vo.AnnexVO;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
@@ -32,6 +33,7 @@ import com.dk.mdm.model.vo.ivt.InboundItemVO;
|
|
|
import com.dk.mdm.model.vo.ivt.InboundVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
import com.dk.mdm.service.ivt.inventory.InventoryService;
|
|
|
+import com.dk.mdm.service.mac.AccountService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -83,7 +85,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
@Autowired
|
|
|
private InventoryService inventoryService;
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private AccountService accountService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -130,7 +133,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//自动办理标识
|
|
|
String flgHandleSetting = commonMapper.getSettingValue(map);
|
|
|
//自动办理标识为1 自动办理入库
|
|
|
- if(Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)){
|
|
|
+ if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
|
|
|
inboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
|
|
|
inboundVO.setFlgAutoHandle(Constant.FlgAutoHandle.TRUE.getValue());
|
|
|
}
|
|
|
@@ -274,10 +277,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //region 已入库调用账款 todo
|
|
|
-// if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus()){
|
|
|
-//
|
|
|
-// }
|
|
|
+ //region 已入库调用账款
|
|
|
+ if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
+ accountService.accPayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
+ }
|
|
|
//endregion
|
|
|
|
|
|
//region 库存
|
|
|
@@ -308,9 +311,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//region 自动办理参数为true 已入库编辑
|
|
|
//自动办理参数为true
|
|
|
if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundVO.getFlgHandleSetting())) {
|
|
|
- //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
+ //region 退账
|
|
|
if (inboundVO.getReceivableId() != null) {
|
|
|
-
|
|
|
+ accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
@@ -385,18 +388,16 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //region todo 入账 当单据红的账款id不为空说明有账, 最后要入账
|
|
|
+ //region 账款
|
|
|
if (inboundVO.getReceivableId() != null) {
|
|
|
-
|
|
|
+ accountService.accPayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
//region todo调用库存
|
|
|
-// if(Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())){
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
// map.put("intoDetail",inboundVO.getItemList());
|
|
|
// inventoryService.updateInventoryInformation(map);
|
|
|
-// }
|
|
|
//endregion
|
|
|
}
|
|
|
//endregion
|
|
|
@@ -436,6 +437,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
|
}
|
|
|
//endregion
|
|
|
+
|
|
|
//region 修改入库总单
|
|
|
Inbound inbound = new Inbound();
|
|
|
inbound.setIntoId(inboundVO.getIntoId());
|
|
|
@@ -446,6 +448,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
);
|
|
|
//endregion
|
|
|
+
|
|
|
//region 修改采购总单
|
|
|
Purchase purchase = new Purchase();
|
|
|
purchase.setPurId(inboundVO.getFromId());
|
|
|
@@ -465,8 +468,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 采购入库作废
|
|
|
- * @date : 2024/3/26 9:24
|
|
|
+ * @desc : 采购入库作废
|
|
|
+ * @date : 2024/3/26 9:24
|
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
@@ -481,9 +484,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//region 自动办理参数为true 已入库编辑
|
|
|
//自动办理参数为true
|
|
|
if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundResponse.getFlgHandleSetting())) {
|
|
|
- //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
+ //region 退账
|
|
|
if (inboundResponse.getReceivableId() != null) {
|
|
|
-
|
|
|
+ accountService.reversePayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
@@ -546,9 +549,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //region todo 入账 当单据红的账款id不为空说明有账, 最后要入账
|
|
|
+ //region 账款
|
|
|
if (inboundResponse.getReceivableId() != null) {
|
|
|
-
|
|
|
+ accountService.accPayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
@@ -639,53 +642,56 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
//入库明细根据id查询
|
|
|
InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
- if (inboundItemVO.getIntoId() != null) {
|
|
|
- //region 将库存需要的参数赋值
|
|
|
- inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
- inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
- //endregion
|
|
|
-
|
|
|
- //region 采购明细
|
|
|
- //根据id查询
|
|
|
- PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
- //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
- PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
- purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
- purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
|
|
|
- purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
|
|
|
- purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
- purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
- //入库状态
|
|
|
- String purItemIntoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
- purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
- purchaseItem.setIntoStatus(purItemIntoStatus);
|
|
|
- int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
- //数量超出
|
|
|
- if (countRow == 0) {
|
|
|
- throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
- }
|
|
|
- //endregion
|
|
|
- //region 编辑入库明细
|
|
|
- inboundItemVO
|
|
|
- .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
|
- .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
- .setIntoingQty(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());
|
|
|
- inboundItemVO.setIntoStatus(intoStatus);
|
|
|
- //实体转换
|
|
|
- InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
- //修改
|
|
|
- inboundItemMapper.update(inboundItem,
|
|
|
- new UpdateWrapper<InboundItem>().lambda()
|
|
|
- .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
- );
|
|
|
- //endregion
|
|
|
+ //region 校验数量是否超出
|
|
|
+ if (inboundItemVO.getIntoingQty().compareTo(inboundItemResponse.getIntoQty()) > 0) {
|
|
|
+ return ResponseResultUtil.error(ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getCode(),
|
|
|
+ ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getMessage());
|
|
|
}
|
|
|
+ //endregion
|
|
|
+ //region 将库存需要的参数赋值
|
|
|
+ inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
+ inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
+ //endregion
|
|
|
+ //region 采购明细
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
+ //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
|
|
|
+ purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
+ purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
+ //入库状态
|
|
|
+ String purItemIntoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
+ purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
+ purchaseItem.setIntoStatus(purItemIntoStatus);
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //region 编辑入库明细
|
|
|
+ inboundItemVO
|
|
|
+ .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
|
|
|
+ .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
+ .setIntoingQty(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());
|
|
|
+ inboundItemVO.setIntoStatus(intoStatus);
|
|
|
+ //实体转换
|
|
|
+ InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
@@ -774,8 +780,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //region todo 调用账款
|
|
|
-
|
|
|
+ //region 账款
|
|
|
+ accountService.accPayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
//endregion
|
|
|
|
|
|
//region todo 调用库存 这里后续把删除的明细也加上
|
|
|
@@ -800,9 +806,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
//endregion
|
|
|
|
|
|
- //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
- if (inboundResponse.getReceivableId() != null) {
|
|
|
-
|
|
|
+ //region 退账
|
|
|
+ if (inboundVO.getReceivableId() != null) {
|
|
|
+ accountService.reversePayable(inboundVO.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
|
|
|
}
|
|
|
//endregion
|
|
|
|