|
|
@@ -13,6 +13,7 @@ import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.common.service.BaseService;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
|
+import com.dk.mdm.mapper.common.CommonMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InboundItemMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
import com.dk.mdm.mapper.pur.PurchaseItemMapper;
|
|
|
@@ -30,6 +31,7 @@ import com.dk.mdm.model.response.pur.PurchaseResponse;
|
|
|
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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -75,6 +77,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
@Autowired
|
|
|
private CommonService commonService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InventoryService inventoryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommonMapper commonMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @desc : 条件查询
|
|
|
@@ -113,6 +121,18 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public ResponseResultVO<?> purchaseInboundInsert(InboundVO inboundVO) {
|
|
|
+ //region 查询当前公司的系统参数 自动办理信息 并赋值
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("cpId", inboundVO.getCpId());
|
|
|
+ map.put("code", "IVT_001");
|
|
|
+ //自动办理标识
|
|
|
+ String flgHandleSetting = commonMapper.getSettingValue(map);
|
|
|
+ //自动办理标识为1 自动办理入库
|
|
|
+ if(Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)){
|
|
|
+ inboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
//region 总单
|
|
|
//获取 id/单号
|
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCASEINBOUND.getName(), false);
|
|
|
@@ -121,7 +141,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//入库类型
|
|
|
inboundVO.setIntoType(Constant.IntoType.SALE.getName());
|
|
|
//自动入库标识
|
|
|
- if (inboundVO.getAutomaticFlg()) {
|
|
|
+ if (inboundVO.getFlgAutoHandle()) {
|
|
|
//已入库
|
|
|
inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
|
|
|
} else {
|
|
|
@@ -154,17 +174,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
//已入库
|
|
|
if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
-// //直接已入库
|
|
|
-// if(purchaseResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
-// purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
-// purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
-// }
|
|
|
-// //多次已入库
|
|
|
-// else{
|
|
|
-// purchaseUpdate.setIntoingQty(inboundVO.getIntoQty().negate());
|
|
|
-// purchaseUpdate.setIntoingAmt(inboundVO.getIntoAmt().negate());
|
|
|
-// }
|
|
|
- //todo 2024年3月25日11:31:52 这里直接赋值0
|
|
|
purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
|
|
|
purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
|
|
|
purchaseUpdate.setIntoQty(inboundVO.getIntoQty());
|
|
|
@@ -198,6 +207,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
}
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
+ //region 将库存需要的参数赋值
|
|
|
+ inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
+ inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
+ //endregion
|
|
|
//总单id
|
|
|
inboundItemVO.setIntoId(inboundVO.getIntoId());
|
|
|
//入库类型
|
|
|
@@ -233,16 +246,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
//已入库
|
|
|
if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
|
|
|
-// //第一次已入库
|
|
|
-// if(purchaseItemResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
|
|
|
-// purchaseItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
-// purchaseItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
-// }
|
|
|
-// //多次已入库
|
|
|
-// else{
|
|
|
-// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
-// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
-// }
|
|
|
//2024年3月25日11:49:17 直接赋值为0
|
|
|
purchaseItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
purchaseItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
@@ -270,16 +273,348 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
+ //region 已入库调用账款 todo
|
|
|
+// if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus()){
|
|
|
+//
|
|
|
+// }
|
|
|
+ //endregion
|
|
|
+
|
|
|
//region 库存
|
|
|
+// if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
|
|
|
+// Map<String, Object> invMap = new HashMap<>();
|
|
|
+// invMap.put("intoDetail",inboundVO.getItemList());
|
|
|
+// inventoryService.updateInventoryInformation(map);
|
|
|
+// }
|
|
|
+ //endregion
|
|
|
|
|
|
|
|
|
+ return ResponseResultUtil.success(inboundVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 采购入库编辑
|
|
|
+ * @date : 2024/3/25 16:25
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public ResponseResultVO<?> purchaseInboundUpdate(InboundVO inboundVO) {
|
|
|
+ //region 根据id查询 此条入库单的数据还未更改前的数据
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
+ BigDecimal sumQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal sumAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
//endregion
|
|
|
|
|
|
+ //region 自动办理参数为true 已入库编辑
|
|
|
+ //自动办理参数为true
|
|
|
+ if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundVO.getFlgHandleSetting())) {
|
|
|
+ //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
+ if (inboundVO.getReceivableId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改明细
|
|
|
+ List<InboundItemVO> itemList = inboundVO.getItemList();
|
|
|
+ for (InboundItemVO inboundItemVO : itemList) {
|
|
|
+ //根据id查询
|
|
|
+ InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
+ //region 将库存需要的参数赋值
|
|
|
+ inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
+ inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
+ //编辑之前的数
|
|
|
+ inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
|
|
|
+ inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
|
|
|
+ //编辑之后的数
|
|
|
+ inboundItemVO.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
+ inboundItemVO.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //赋值
|
|
|
+ InboundItem inboundItem = new InboundItem();
|
|
|
+ inboundItem.setItemId(inboundItemVO.getItemId());
|
|
|
+ inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
|
|
|
+ inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+
|
|
|
+ //region 销售明细
|
|
|
+ if (inboundItemVO.getFromItemId() != null) {
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ purchaseItem.setIntoQty(inboundItemResponse.getIntoQty().negate().add(inboundItemVO.getIntoingQty()));
|
|
|
+ purchaseItem.setIntoAmt(inboundItemResponse.getIntoAmt().negate().add(inboundItemVO.getIntoingAmt()));
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改入库总单
|
|
|
+ Inbound inbound = new Inbound();
|
|
|
+ inbound.setIntoId(inboundVO.getIntoId());
|
|
|
+ inbound.setIntoQty(sumQty);
|
|
|
+ inbound.setIntoAmt(sumAmt);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改销售总单
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundVO.getFromId());
|
|
|
+ purchase.setIntoQty(inboundResponse.getIntoQty().negate().add(sumQty));
|
|
|
+ purchase.setIntoAmt(inboundResponse.getIntoAmt().negate().add(sumAmt));
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region todo 入账 当单据红的账款id不为空说明有账, 最后要入账
|
|
|
+ if (inboundVO.getReceivableId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //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
|
|
|
+
|
|
|
+ //region 自动办理参数false 入库中编辑
|
|
|
+ //自动办理标识为false 并且 自动办理参数为false 入库中
|
|
|
+ if (!inboundVO.getFlgAutoHandle() && Constant.FlgHandleSetting.FALSE.getValue().equals(inboundVO.getFlgHandleSetting())) {
|
|
|
+ //region 修改明细
|
|
|
+ List<InboundItemVO> itemList = inboundVO.getItemList();
|
|
|
+ for (InboundItemVO inboundItemVO : itemList) {
|
|
|
+ //根据id查询 获取到还未进行修改的数据
|
|
|
+ InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
|
|
|
+ //赋值
|
|
|
+ InboundItem inboundItem = new InboundItem();
|
|
|
+ inboundItem.setItemId(inboundItemVO.getItemId());
|
|
|
+ inboundItem.setIntoingQty(inboundItemVO.getIntoingQty());
|
|
|
+ inboundItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ //region 销售明细
|
|
|
+ if (inboundItemVO.getFromItemId() != null) {
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
+ //本次修改几个传几个(负数) sql中是原数据+本次修改数据
|
|
|
+ purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate().add(inboundItemVO.getIntoingQty()));
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate().add(inboundItemVO.getIntoingAmt()));
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //region 修改入库总单
|
|
|
+ Inbound inbound = new Inbound();
|
|
|
+ inbound.setIntoId(inboundVO.getIntoId());
|
|
|
+ inbound.setIntoingQty(sumQty);
|
|
|
+ inbound.setIntoAmt(sumAmt);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+ //region 修改销售总单
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundVO.getFromId());
|
|
|
+ purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().add(sumQty));
|
|
|
+ purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().add(sumAmt));
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
|
|
|
return ResponseResultUtil.success(inboundVO);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc : 采购入库作废
|
|
|
+ * @date : 2024/3/26 9:24
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public ResponseResultVO<?> purchaseInboundRepeal(String intoId) {
|
|
|
+ //region 查询总单 查询明细
|
|
|
+ //根据id查询 此条入库单的数据还未更改前的数据
|
|
|
+ InboundResponse inboundResponse = inboundMapper.selectById(intoId);
|
|
|
+ //根据总单id查询
|
|
|
+ List<InboundItemResponse> inboundItemResponseList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inboundResponse.getIntoId()));
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 自动办理参数为true 已入库编辑
|
|
|
+ //自动办理参数为true
|
|
|
+ if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundResponse.getFlgHandleSetting())) {
|
|
|
+ //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
+ if (inboundResponse.getReceivableId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改明细
|
|
|
+ for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
|
|
|
+ //region 将库存需要的参数赋值
|
|
|
+ inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
+ inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
+ inboundItemResponse.setIntoQty(inboundItemResponse.getIntoQty().negate());
|
|
|
+ inboundItemResponse.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //赋值
|
|
|
+ InboundItem inboundItem = new InboundItem();
|
|
|
+ inboundItem.setItemId(inboundItemResponse.getItemId());
|
|
|
+ inboundItem.setFlgValid(false);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+
|
|
|
+ //region 销售明细
|
|
|
+ if (inboundItemResponse.getFromItemId() != null) {
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemResponse.getFromItemId());
|
|
|
+ purchaseItem.setIntoQty(BigDecimal.ZERO);
|
|
|
+ purchaseItem.setIntoAmt(BigDecimal.ZERO);
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改入库总单
|
|
|
+ Inbound inbound = new Inbound();
|
|
|
+ inbound.setIntoId(inboundResponse.getIntoId());
|
|
|
+ inbound.setFlgValid(false);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 修改销售总单
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundResponse.getFromId());
|
|
|
+ purchase.setIntoQty(BigDecimal.ZERO);
|
|
|
+ purchase.setIntoQty(BigDecimal.ZERO);
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region todo 入账 当单据红的账款id不为空说明有账, 最后要入账
|
|
|
+ if (inboundResponse.getReceivableId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region todo 调用库存
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("intoDetail",inboundItemResponseList);
|
|
|
+// inventoryService.updateInventoryInformation(map);
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 自动办理参数false 入库中编辑
|
|
|
+ //自动办理标识为false 并且 自动办理参数为false 入库中
|
|
|
+ if (!inboundResponse.getFlgAutoHandle() && Constant.FlgHandleSetting.FALSE.getValue().equals(inboundResponse.getFlgHandleSetting())) {
|
|
|
+ //region 修改明细
|
|
|
+ for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
|
|
|
+ //赋值
|
|
|
+ InboundItem inboundItem = new InboundItem();
|
|
|
+ inboundItem.setItemId(inboundItemResponse.getItemId());
|
|
|
+ inboundItem.setIntoingQty(BigDecimal.ZERO);
|
|
|
+ inboundItem.setIntoingAmt(BigDecimal.ZERO);
|
|
|
+ //修改
|
|
|
+ inboundItemMapper.update(inboundItem,
|
|
|
+ new UpdateWrapper<InboundItem>().lambda()
|
|
|
+ .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ //region 销售明细
|
|
|
+ if (inboundItemResponse.getFromItemId() != null) {
|
|
|
+ //根据id查询
|
|
|
+ PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
+ purchaseItem.setItemId(inboundItemResponse.getFromItemId());
|
|
|
+ purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
|
|
|
+ purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
|
|
|
+ int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //region 修改入库总单
|
|
|
+ Inbound inbound = new Inbound();
|
|
|
+ inbound.setIntoId(inboundResponse.getIntoId());
|
|
|
+ inbound.setIntoingQty(BigDecimal.ZERO);
|
|
|
+ inbound.setIntoAmt(BigDecimal.ZERO);
|
|
|
+ //修改
|
|
|
+ inboundMapper.update(inbound,
|
|
|
+ new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
|
|
|
+ );
|
|
|
+ //endregion
|
|
|
+ //region 修改销售总单
|
|
|
+ Purchase purchase = new Purchase();
|
|
|
+ purchase.setPurId(inboundResponse.getFromId());
|
|
|
+ purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
|
|
|
+ purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
|
|
|
+ //修改
|
|
|
+ int countRow = purchaseMapper.updateById(purchase);
|
|
|
+ //数量超出
|
|
|
+ if (countRow == 0) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ return ResponseResultUtil.success();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @desc : 采购入库办理
|
|
|
@@ -288,16 +623,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
|
|
|
- //region 根据订单id查询入库数据
|
|
|
- List<InboundResponse> inboundResponses = inboundMapper.selectByCond(new InboundQuery().setFromId(inboundVO.getFromId()));
|
|
|
- BigDecimal intoingQtyTotal = BigDecimal.ZERO;
|
|
|
- BigDecimal intoingAmtTotal = BigDecimal.ZERO;
|
|
|
- if (inboundResponses != null && inboundResponses.size() > 0) {
|
|
|
- //入库中数据 汇总
|
|
|
- intoingQtyTotal = inboundResponses.stream().map(InboundResponse::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- intoingAmtTotal = inboundResponses.stream().map(InboundResponse::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
- }
|
|
|
- //endregion
|
|
|
//region 根据id查询 此条入库单的数据还未更改前的数据
|
|
|
InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
//endregion
|
|
|
@@ -312,15 +637,17 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//入库明细根据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());
|
|
|
- //todo 取入库单的入库中数据
|
|
|
-// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
-// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
|
|
|
purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
|
|
|
purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
@@ -341,9 +668,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
|
|
|
.setIntoQty(inboundItemResponse.getOutQty().add(inboundItemVO.getIntoQty()))
|
|
|
.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()))
|
|
|
-// .setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
|
|
|
-// .setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
|
|
|
- //todo 2024年3月25日12:57:07 直接赋值为0
|
|
|
.setIntoingQty(BigDecimal.ZERO)
|
|
|
.setIntoingAmt(BigDecimal.ZERO)
|
|
|
.setCostPrice(inboundItemVO.getPriceInto())
|
|
|
@@ -363,64 +687,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
}
|
|
|
//endregion
|
|
|
-// //region 新建明细 todo 注释掉
|
|
|
-// else {
|
|
|
-// inboundItemVO
|
|
|
-// .setIntoQty(inboundItemVO.getIntoingQty())
|
|
|
-// .setIntoAmt(inboundItemVO.getIntoingAmt())
|
|
|
-// //todo 2024年3月25日12:58:01 赋值0
|
|
|
-// .setIntoingQty(BigDecimal.ZERO)
|
|
|
-// .setIntoAmt(BigDecimal.ZERO)
|
|
|
-// .setIntoId(inboundVO.getIntoId())
|
|
|
-// .setCostPrice(inboundItemVO.getPriceInto())
|
|
|
-// .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
|
|
|
-// .setIntoType(Constant.IntoType.SALE.getName());
|
|
|
-// //入库状态
|
|
|
-// String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
|
|
|
-// inboundItemVO.setIntoStatus(intoStatus);
|
|
|
-// //实体转换
|
|
|
-// InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
-// //新建
|
|
|
-// inboundItemMapper.insert(inboundItem);
|
|
|
-// }
|
|
|
-// //endregion
|
|
|
-
|
|
|
- //region 采购 todo 注释掉
|
|
|
- //采购明细
|
|
|
-// if (inboundItemVO.getFromItemId() != null) {
|
|
|
-// //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
-// PurchaseItem purchaseItem = new PurchaseItem();
|
|
|
-// purchaseItem.setItemId(inboundItemVO.getFromItemId());
|
|
|
-// purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
|
|
|
-// purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
|
|
|
-// purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
|
|
|
-// purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
|
|
|
-// //根据id查询
|
|
|
-// PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
|
|
|
-// //入库状态
|
|
|
-// String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
|
|
|
-// purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
|
|
|
-// purchaseItem.setIntoStatus(intoStatus);
|
|
|
-// int countRow = purchaseItemMapper.updateById(purchaseItem);
|
|
|
-// //数量超出
|
|
|
-// if (countRow == 0) {
|
|
|
-// throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
|
|
|
-// }
|
|
|
-// }
|
|
|
- //endregion
|
|
|
-// }
|
|
|
- //endregion
|
|
|
|
|
|
- //region 删除明细 todo 2024年3月20日13:14:20 这里可能用不到
|
|
|
-// BigDecimal sumDelIntoQty = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
|
|
|
-// BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
|
|
|
+ //region 删除明细
|
|
|
if (inboundVO.getDeleteItemList() != null) {
|
|
|
-// sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
-// sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
|
|
|
if (inboundItemVO.getItemId() != null) {
|
|
|
InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
@@ -467,8 +736,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
inboundVO.setIntoAmt(sumIntoAmt);
|
|
|
inboundVO.setIntoingQty(BigDecimal.ZERO);
|
|
|
inboundVO.setIntoingAmt(BigDecimal.ZERO);
|
|
|
-// inboundVO.setIntoingQty(inboundResponse.getIntoingQty());
|
|
|
-// inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
|
|
|
//入库状态
|
|
|
String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
|
|
|
inboundVO.setIntoStatus(intoStatus);
|
|
|
@@ -485,12 +752,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
Purchase purchase = new Purchase();
|
|
|
purchase.setPurId(inboundVO.getFromId());
|
|
|
- //region todo 2024年3月20日13:14:51 这里可能用不到
|
|
|
-// purchase.setIntoQty(sumIntoQty.subtract(sumDelIntoQty));
|
|
|
-// purchase.setIntoAmt(sumIntoAmt.subtract(sumDelIntoAmt));
|
|
|
-// purchase.setIntoingQty((sumIntoingQty.add(sumDelIntoingQty)).negate());
|
|
|
-// purchase.setIntoingAmt((sumIntoingAmt.add(sumDelIntoingAmt)).negate());
|
|
|
- //endregion
|
|
|
purchase.setIntoQty(sumIntoQty);
|
|
|
purchase.setIntoAmt(sumIntoAmt);
|
|
|
//todo 2024年3月25日14:50:41 取
|
|
|
@@ -498,8 +759,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
|
|
|
purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
|
|
|
}
|
|
|
-// purchase.setIntoingQty(sumIntoQty.negate());
|
|
|
-// purchase.setIntoingAmt(sumIntoAmt.negate());
|
|
|
//根据id查询
|
|
|
PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
|
|
|
//入库状态
|
|
|
@@ -515,8 +774,15 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- //todo 如果是已入库 调用库存 后续写库存这里补上
|
|
|
- //region 修改库存
|
|
|
+ //region todo 调用账款
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region todo 调用库存
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("intoDetail",inboundItemResponseList);
|
|
|
+// inventoryService.updateInventoryInformation(map);
|
|
|
+ //endregion
|
|
|
|
|
|
//endregion
|
|
|
return ResponseResultUtil.success(inboundVO);
|
|
|
@@ -534,6 +800,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
|
|
|
//endregion
|
|
|
|
|
|
+ //region todo 退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
|
|
|
+ if (inboundResponse.getReceivableId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
//region 修改订单数据信息
|
|
|
if (inboundResponse.getFromId() != null) {
|
|
|
//赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
@@ -603,6 +875,14 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
|
|
|
//region修改入库明细信息
|
|
|
InboundItem inboundItem = new InboundItem();
|
|
|
+
|
|
|
+ //region 将库存需要的参数赋值
|
|
|
+ inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
+ inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
|
|
|
+ inboundItemResponse.setIntoQty(inboundItemResponse.getIntoQty().negate());
|
|
|
+ inboundItemResponse.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
|
|
|
+ //endregion
|
|
|
+
|
|
|
inboundItem
|
|
|
.setIntoId(inbound.getIntoId())
|
|
|
.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
|
|
|
@@ -613,6 +893,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
.setCostPrice(BigDecimal.ZERO)
|
|
|
.setCostAmt(BigDecimal.ZERO)
|
|
|
.setItemId(inboundItemResponse.getItemId());
|
|
|
+ //入库状态
|
|
|
+ String intoStatus = this.setIntoStatus(inboundItem.getIntoingQty(), inboundItem.getIntoQty());
|
|
|
+ inboundItem.setIntoStatus(intoStatus);
|
|
|
//修改
|
|
|
inboundItemMapper.update(inboundItem,
|
|
|
new UpdateWrapper<InboundItem>().lambda()
|
|
|
@@ -623,9 +906,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
- //todo 调用库存 后续写库存这里补上
|
|
|
- //region 修改库存
|
|
|
-
|
|
|
+ //region todo 调用库存
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("intoDetail",inboundItemResponseList);
|
|
|
+// inventoryService.updateInventoryInformation(map);
|
|
|
//endregion
|
|
|
|
|
|
return ResponseResultUtil.success();
|