|
|
|
@ -344,7 +344,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
//更新退库记录执行状态
|
|
|
|
|
wmsRawReturn.setExecuteStatus( WmsConstants.WMS_EXECUTE_STATUS_FINISH);
|
|
|
|
|
wmsRawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
|
|
|
|
|
wmsRawReturn.setLocationCode(locationCode);
|
|
|
|
|
wmsRawReturn.setReturnAmount(returnAmount);
|
|
|
|
|
wmsRawReturn.setUpdateDate(currentDate);
|
|
|
|
@ -465,67 +465,77 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public int applyRawReturn(List<WmsRawReturn> wmsRawReturns) {
|
|
|
|
|
//申请退库不指定库位,申请退库的多个物料生成多条退库记录
|
|
|
|
|
//申请退库不指定库位,申请退库的多个物料生成多条退库记录,目前按每个条码物料申请退库
|
|
|
|
|
//根据仓库ID分组获取总申请数量
|
|
|
|
|
Map<Long, List<WmsRawReturn>> rawReturnsMap = wmsRawReturns.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(WmsRawReturn::getWarehouseId));
|
|
|
|
|
// Map<Long, List<WmsRawReturn>> rawReturnsMap = wmsRawReturns.stream()
|
|
|
|
|
// .collect(Collectors.groupingBy(WmsRawReturn::getWarehouseId));
|
|
|
|
|
WmsRawReturn firstWmsRawReturn = wmsRawReturns.get(0);
|
|
|
|
|
Long warehouseId = firstWmsRawReturn.getWarehouseId();
|
|
|
|
|
WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
|
|
|
|
|
String warehouseType = baseWarehouse.getWarehouseType();
|
|
|
|
|
String returnRequirement = baseWarehouse.getReturnRequirement();
|
|
|
|
|
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
|
|
|
|
|
String auditStatus = "";
|
|
|
|
|
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {//如果是普通仓库,需要校验审核标识
|
|
|
|
|
if (returnRequirement.equals(WmsConstants.WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT)) {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_TOAUDIT;
|
|
|
|
|
} else {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsRawReturn> toInsertedRawReturns = new ArrayList<>();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
String taskCode = Seq.getId(Seq.rawReturnSeqType, Seq.rawReturnCode);
|
|
|
|
|
for (Long warehouseId : rawReturnsMap.keySet()) {
|
|
|
|
|
List<WmsRawReturn> rawReturnList = rawReturnsMap.get(warehouseId);
|
|
|
|
|
WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
|
|
|
|
|
String warehouseType = baseWarehouse.getWarehouseType();
|
|
|
|
|
String returnRequirement = baseWarehouse.getReturnRequirement();
|
|
|
|
|
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
|
|
|
|
|
String auditStatus = "";
|
|
|
|
|
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {//如果是普通仓库,需要校验审核标识
|
|
|
|
|
if (returnRequirement.equals(WmsConstants.WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT)) {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_TOAUDIT;
|
|
|
|
|
} else {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
|
|
|
|
|
for (WmsRawReturn rawReturn : wmsRawReturns) {
|
|
|
|
|
BigDecimal planAmount = rawReturn.getPlanAmount();
|
|
|
|
|
if (planAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
throw new ServiceException("数量需大于0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (WmsRawReturn rawReturn : rawReturnList) {
|
|
|
|
|
BigDecimal planAmount = rawReturn.getPlanAmount();
|
|
|
|
|
if (planAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
throw new ServiceException("数量需大于0");
|
|
|
|
|
}
|
|
|
|
|
String materialBarcode = rawReturn.getMaterialBarcode();
|
|
|
|
|
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
|
|
|
|
|
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
|
|
|
|
|
if (baseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("物料编码有误");
|
|
|
|
|
}
|
|
|
|
|
String batchFlag = baseBarcodeInfo.getBatchFlag();
|
|
|
|
|
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
|
|
|
|
|
if (planAmount.compareTo(BigDecimal.ONE) != 0) {
|
|
|
|
|
throw new ServiceException("非批次物料数量需等于1");
|
|
|
|
|
}
|
|
|
|
|
String materialBarcode = rawReturn.getMaterialBarcode();
|
|
|
|
|
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
|
|
|
|
|
if (baseBarcodeInfoR == null) {
|
|
|
|
|
throw new ServiceException("物料编码有误");
|
|
|
|
|
}
|
|
|
|
|
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
|
|
|
|
|
if (baseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("物料编码有误");
|
|
|
|
|
}
|
|
|
|
|
String batchFlag = baseBarcodeInfo.getBatchFlag();
|
|
|
|
|
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
|
|
|
|
|
if (planAmount.compareTo(BigDecimal.ONE) != 0) {
|
|
|
|
|
throw new ServiceException("非批次物料数量需等于1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
|
|
|
|
|
throw new ServiceException("物料编码有误,此物料编码非原材料编码");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rawReturn.setTaskCode(taskCode);
|
|
|
|
|
rawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
|
|
|
|
|
rawReturn.setEndStationCode(baseWarehouse.getAgvPositionCode());
|
|
|
|
|
rawReturn.setOperationType(operationType);
|
|
|
|
|
rawReturn.setAuditStatus(auditStatus);
|
|
|
|
|
rawReturn.setReturnAmount(BigDecimal.ZERO);
|
|
|
|
|
rawReturn.setMaterialId(baseBarcodeInfo.getMaterialId());
|
|
|
|
|
rawReturn.setBatchCode(baseBarcodeInfo.getBatchCode());
|
|
|
|
|
rawReturn.setApplyBy(userName);
|
|
|
|
|
rawReturn.setApplyDate(currentDate);
|
|
|
|
|
toInsertedRawReturns.add(rawReturn);
|
|
|
|
|
WmsRawStock existedRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode);
|
|
|
|
|
if (existedRawStock != null && existedRawStock.getTotalAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
throw new ServiceException("此物料条码在仓库中存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsRawReturnMapper.batchWmsRawReturn(toInsertedRawReturns);
|
|
|
|
|
rawReturn.setTaskCode(taskCode);
|
|
|
|
|
rawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
|
|
|
|
|
rawReturn.setEndStationCode(baseWarehouse.getAgvPositionCode());
|
|
|
|
|
rawReturn.setOperationType(operationType);
|
|
|
|
|
rawReturn.setAuditStatus(auditStatus);
|
|
|
|
|
rawReturn.setReturnAmount(BigDecimal.ZERO);
|
|
|
|
|
rawReturn.setMaterialId(baseBarcodeInfo.getMaterialId());
|
|
|
|
|
rawReturn.setBatchCode(baseBarcodeInfo.getBatchCode());
|
|
|
|
|
rawReturn.setApplyBy(userName);
|
|
|
|
|
rawReturn.setApplyDate(currentDate);
|
|
|
|
|
toInsertedRawReturns.add(rawReturn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsRawReturnMapper.batchWmsRawReturn(toInsertedRawReturns);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|