mirror of
https://github.com/zccbbg/wms-ruoyi.git
synced 2024-11-10 17:13:51 +08:00
部分出库/出库完成的出库单 支持删除,同时删除库存历史记录、库存数量回滚。
This commit is contained in:
parent
fc6122e006
commit
9f3969e547
4 changed files with 72 additions and 27 deletions
|
@ -2,11 +2,11 @@ package com.cyl.wms.constant;
|
|||
|
||||
public interface ShipmentOrderConstant {
|
||||
|
||||
// 未入库
|
||||
// 未出库
|
||||
int NOT_IN = 11;
|
||||
// 部分入库
|
||||
// 部分出库
|
||||
int PART_IN = 12;
|
||||
// 全部入库
|
||||
// 全部出库
|
||||
int ALL_IN = 13;
|
||||
// 作废
|
||||
int DROP = 14;
|
||||
|
|
|
@ -103,6 +103,7 @@ public class InventoryMovementService {
|
|||
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
||||
}
|
||||
QueryWrapper<InventoryMovement> qw = new QueryWrapper<>();
|
||||
qw.orderByDesc("id");
|
||||
qw.eq("del_flag", 0);
|
||||
String inventoryMovementNo = query.getInventoryMovementNo();
|
||||
if (!StringUtils.isEmpty(inventoryMovementNo)) {
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
package com.cyl.wms.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cyl.wms.convert.ShipmentOrderDetailConvert;
|
||||
import com.cyl.wms.domain.ReceiptOrderDetail;
|
||||
import com.cyl.wms.pojo.vo.ReceiptOrderDetailVO;
|
||||
import com.cyl.wms.domain.ShipmentOrder;
|
||||
import com.cyl.wms.domain.ShipmentOrderDetail;
|
||||
import com.cyl.wms.mapper.ShipmentOrderDetailMapper;
|
||||
import com.cyl.wms.pojo.query.ShipmentOrderDetailQuery;
|
||||
import com.cyl.wms.pojo.vo.ShipmentOrderDetailVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.cyl.wms.mapper.ShipmentOrderDetailMapper;
|
||||
import com.cyl.wms.domain.ShipmentOrderDetail;
|
||||
import com.cyl.wms.pojo.query.ShipmentOrderDetailQuery;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出库单详情Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
|
@ -54,7 +52,7 @@ public class ShipmentOrderDetailService {
|
|||
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
|
||||
}
|
||||
QueryWrapper<ShipmentOrderDetail> qw = new QueryWrapper<>();
|
||||
qw.eq("del_flag",0);
|
||||
qw.eq("del_flag", 0);
|
||||
Long shipmentOrderId = query.getShipmentOrderId();
|
||||
if (shipmentOrderId != null) {
|
||||
qw.eq("shipment_order_id", shipmentOrderId);
|
||||
|
@ -79,17 +77,17 @@ public class ShipmentOrderDetailService {
|
|||
}
|
||||
|
||||
|
||||
public List<ShipmentOrderDetailVO> toVos(List<ShipmentOrderDetail> items){
|
||||
public List<ShipmentOrderDetailVO> toVos(List<ShipmentOrderDetail> items) {
|
||||
List<ShipmentOrderDetailVO> list = convert.dos2vos(items);
|
||||
list.forEach(itemVO ->{
|
||||
list.forEach(itemVO -> {
|
||||
List<Long> place = new LinkedList<>();
|
||||
if(itemVO.getWarehouseId()!=null){
|
||||
if (itemVO.getWarehouseId() != null) {
|
||||
place.add(itemVO.getWarehouseId());
|
||||
}
|
||||
if(itemVO.getAreaId()!=null){
|
||||
if (itemVO.getAreaId() != null) {
|
||||
place.add(itemVO.getAreaId());
|
||||
}
|
||||
if(itemVO.getRackId()!=null){
|
||||
if (itemVO.getRackId() != null) {
|
||||
place.add(itemVO.getRackId());
|
||||
}
|
||||
itemVO.setPlace(place);
|
||||
|
@ -139,4 +137,12 @@ public class ShipmentOrderDetailService {
|
|||
Long[] ids = {id};
|
||||
return shipmentOrderDetailMapper.updateDelFlagByIds(ids);
|
||||
}
|
||||
|
||||
public void updateDelFlag(ShipmentOrder shipmentOrder) {
|
||||
LambdaUpdateWrapper<ShipmentOrderDetail> updateWrapper = new LambdaUpdateWrapper<ShipmentOrderDetail>()
|
||||
.eq(ShipmentOrderDetail::getShipmentOrderId, shipmentOrder.getId())
|
||||
.set(ShipmentOrderDetail::getDelFlag, 1);
|
||||
shipmentOrderDetailMapper.update(null, updateWrapper);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,8 +177,46 @@ public class ShipmentOrderService {
|
|||
* @param ids 需要删除的出库单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
public int deleteByIds(Long[] ids) {
|
||||
return shipmentOrderMapper.updateDelFlagByIds(ids);
|
||||
int flag = 0;
|
||||
for (Long id : ids) {
|
||||
ShipmentOrder shipmentOrder = shipmentOrderMapper.selectById(id);
|
||||
if (shipmentOrder == null) {
|
||||
continue;
|
||||
}
|
||||
Integer shipmentOrderStatus = shipmentOrder.getShipmentOrderStatus();
|
||||
|
||||
// 1. 逻辑删除出库单
|
||||
flag += shipmentOrderMapper.updateDelFlagByIds(ids);
|
||||
|
||||
// 2. 逻辑删除出库单详情
|
||||
shipmentOrderDetailService.updateDelFlag(shipmentOrder);
|
||||
|
||||
if (shipmentOrderStatus != ShipmentOrderConstant.ALL_IN && shipmentOrderStatus != ShipmentOrderConstant.PART_IN) {
|
||||
// 未出库的可以直接删除
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. 查询库存记录
|
||||
List<InventoryHistory> inventoryHistories = inventoryHistoryService.selectByForm(shipmentOrder.getId(), shipmentOrder.getShipmentOrderType());
|
||||
|
||||
// 翻转库存记录的数量
|
||||
inventoryHistories.forEach(it -> {
|
||||
it.setQuantity(it.getQuantity().negate());
|
||||
log.info("回滚库存:{} 数量:{}", it.getWarehouseId() + "_" + it.getAreaId() + "_" + it.getRackId() + "_" + it.getItemId(), it.getQuantity());
|
||||
});
|
||||
|
||||
// 4. 回滚库存
|
||||
inventoryService.batchUpdate1(inventoryHistories);
|
||||
|
||||
// 5. 删除库存记录
|
||||
inventoryHistoryService.deleteByForm(shipmentOrder.getId(), shipmentOrder.getShipmentOrderType());
|
||||
|
||||
// todo 6. 回滚供应商流水
|
||||
// supplierTransactionService.deleteByForm(shipmentOrder.getId(), shipmentOrder.getReceiptOrderType());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,7 +251,7 @@ public class ShipmentOrderService {
|
|||
QueryWrapper<ShipmentOrderDetail> qw = new QueryWrapper<>();
|
||||
qw.eq("shipment_order_id", order.getId());
|
||||
|
||||
// 新旧入库单详情对比, 生成 库存记录修改
|
||||
// 新旧出库单详情对比, 生成 库存记录修改
|
||||
List<ShipmentOrderDetailVO> details = order.getDetails();
|
||||
Map<Long, ShipmentOrderDetail> dbDetailMap = shipmentOrderDetailMapper.selectList(qw).stream().collect(Collectors.toMap(ShipmentOrderDetail::getId, it -> it));
|
||||
List<InventoryHistory> adds = new ArrayList<>();
|
||||
|
@ -279,15 +317,15 @@ public class ShipmentOrderService {
|
|||
order.setShipmentOrderStatus(statusList.iterator().next());
|
||||
} else if (statusList.size() == 2) {
|
||||
if (statusList.contains(ShipmentOrderConstant.DROP) && statusList.contains(ShipmentOrderConstant.ALL_IN)) {
|
||||
//此时单据状态只有报废和全部入库,则出库单状态为全部入库
|
||||
//此时单据状态只有报废和全部出库,则出库单状态为全部出库
|
||||
order.setShipmentOrderStatus(ShipmentOrderConstant.ALL_IN);
|
||||
} else if (statusList.contains(ShipmentOrderConstant.PART_IN) || statusList.contains(ShipmentOrderConstant.ALL_IN)) {
|
||||
//此时单据状态有两个,包含部分入库和全部入库都是部分入库
|
||||
//此时单据状态有两个,包含部分出库和全部出库都是部分出库
|
||||
order.setShipmentOrderStatus(ShipmentOrderConstant.PART_IN);
|
||||
}
|
||||
|
||||
} else if (statusList.contains(ShipmentOrderConstant.PART_IN) || statusList.contains(ShipmentOrderConstant.ALL_IN)) {
|
||||
//此时单据状态有两个,包含部分入库和全部入库都是部分入库
|
||||
//此时单据状态有两个,包含部分出库和全部出库都是部分出库
|
||||
order.setShipmentOrderStatus(ShipmentOrderConstant.PART_IN);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue