|
|
|
@ -1243,7 +1243,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BigDecimal directOutstockUpdateRawStock(String locationCode, String materialBarcode, BigDecimal outstockAmount,
|
|
|
|
|
String userName, Date currentDate) {
|
|
|
|
|
String userName, Date currentDate) {
|
|
|
|
|
WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode);
|
|
|
|
|
if (wmsRawStock == null) {
|
|
|
|
|
throw new ServiceException("没找到库存信息");
|
|
|
|
@ -1313,4 +1313,98 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
|
|
|
|
|
wmsRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_SPLIT);
|
|
|
|
|
return wmsRawOutstockMapper.selectNewestWmsRawOutstock(wmsRawOutstock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 退货出库
|
|
|
|
|
* @param wmsReturnOutstockVo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public int returnOutstock(WmsReturnOutstockVo wmsReturnOutstockVo) {
|
|
|
|
|
String locationCode = wmsReturnOutstockVo.getLocationCode();
|
|
|
|
|
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(locationCode);
|
|
|
|
|
if (baseLocation == null) {
|
|
|
|
|
throw new ServiceException("库位编码错误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(baseLocation.getWarehouseId());
|
|
|
|
|
String warehouseType = baseWarehouse.getWarehouseType();
|
|
|
|
|
String executeStatus = "";
|
|
|
|
|
BigDecimal outstockAmount = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal realOutstockAmount = BigDecimal.ZERO;
|
|
|
|
|
WmsRawStock wmsRawStock;
|
|
|
|
|
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_AGV)) {//AGV仓库
|
|
|
|
|
executeStatus = WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE;
|
|
|
|
|
outstockAmount = BigDecimal.ONE;
|
|
|
|
|
WmsRawStock queryRawStock = new WmsRawStock();
|
|
|
|
|
queryRawStock.setLocationCode(locationCode);
|
|
|
|
|
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStockInList(queryRawStock);
|
|
|
|
|
if (wmsRawStocks == null || wmsRawStocks.isEmpty()) {
|
|
|
|
|
throw new ServiceException("此库位无库存信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsRawStock = wmsRawStocks.get(0);
|
|
|
|
|
|
|
|
|
|
} else if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {
|
|
|
|
|
executeStatus = WmsConstants.WMS_EXECUTE_STATUS_FINISH;
|
|
|
|
|
String materialBarcode = wmsReturnOutstockVo.getMaterialBarcode();
|
|
|
|
|
BigDecimal returnAmount = wmsReturnOutstockVo.getReturnAmount();
|
|
|
|
|
outstockAmount = returnAmount;
|
|
|
|
|
realOutstockAmount = returnAmount;
|
|
|
|
|
if (StringUtils.isEmpty(materialBarcode)) {
|
|
|
|
|
throw new ServiceException("请输入或扫描物料条码");
|
|
|
|
|
}
|
|
|
|
|
if (returnAmount == null) {
|
|
|
|
|
throw new ServiceException("请输入退货数量");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode);
|
|
|
|
|
if (wmsRawStock == null) {
|
|
|
|
|
throw new ServiceException("无库存信息");
|
|
|
|
|
}
|
|
|
|
|
BigDecimal totalAmount = wmsRawStock.getTotalAmount();
|
|
|
|
|
BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
|
|
|
|
|
BigDecimal availableAmount = totalAmount.subtract(occupyAmount);
|
|
|
|
|
if (returnAmount.compareTo(availableAmount) > 0) {
|
|
|
|
|
throw new ServiceException("可用库存只有:" + availableAmount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (returnAmount.compareTo(totalAmount) == 0) {
|
|
|
|
|
wmsRawStockMapper.deleteWmsRawStockByRawStockId(wmsRawStock.getRawStockId());
|
|
|
|
|
} else {
|
|
|
|
|
wmsRawStock.setTotalAmount(totalAmount.subtract(returnAmount));
|
|
|
|
|
wmsRawStock.setUpdateBy(userName);
|
|
|
|
|
wmsRawStock.setUpdateDate(currentDate);
|
|
|
|
|
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
throw new ServiceException("仓库类型有误");
|
|
|
|
|
}
|
|
|
|
|
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
|
|
|
|
|
|
|
|
|
|
WmsRawOutstock wmsRawOutstock = new WmsRawOutstock();
|
|
|
|
|
wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode));
|
|
|
|
|
wmsRawOutstock.setWarehouseId(baseWarehouse.getWarehouseId());
|
|
|
|
|
wmsRawOutstock.setLocationCode(locationCode);
|
|
|
|
|
wmsRawOutstock.setSaleOrderId(wmsRawStock.getSaleOrderId());
|
|
|
|
|
wmsRawOutstock.setMaterialId(wmsRawStock.getMaterialId());
|
|
|
|
|
wmsRawOutstock.setMaterialBatch(wmsRawStock.getInstockBatch());
|
|
|
|
|
wmsRawOutstock.setOutstockAmount(outstockAmount);
|
|
|
|
|
wmsRawOutstock.setRealOutstockAmount(realOutstockAmount);
|
|
|
|
|
wmsRawOutstock.setOperationType(operationType);
|
|
|
|
|
wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
|
|
|
|
|
wmsRawOutstock.setExecuteStatus(executeStatus);
|
|
|
|
|
wmsRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_RETURN_OUTSTOCK);
|
|
|
|
|
wmsRawOutstock.setApplyBy(userName);
|
|
|
|
|
wmsRawOutstock.setApplyDate(currentDate);
|
|
|
|
|
|
|
|
|
|
return wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|