|
|
|
@ -95,31 +95,11 @@ public class InvProductsTrService {
|
|
|
|
|
|
|
|
|
|
if (bussinessTypeEntity.isPreIn()) {
|
|
|
|
|
InvProductEntity invPreProductEntity = null;
|
|
|
|
|
// invPreInProductService.selectByUuid(erpOrderEntity.getGoodsid(), erpOrderEntity.getBatchNo(), warehouseEntity.getSupId()
|
|
|
|
|
// , warehouseEntity.getLocStorageCode(), warehouseEntity.getInvWarehouseCode());
|
|
|
|
|
if (invPreProductEntity == null) {
|
|
|
|
|
invPreProductEntity = buildInvPreInProduct(orderEntity, erpOrderEntity, warehouseEntity);
|
|
|
|
|
invPreProductEntity.setUpdateTime(new Date());
|
|
|
|
|
invPreInProductService.insertInvProduct(invPreProductEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* else {
|
|
|
|
|
* int actCount = getActCount(warehouseEntity);
|
|
|
|
|
* int count = actCount * warehouseEntity.getCount();
|
|
|
|
|
* if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
|
|
|
|
|
* invPreProductEntity.setOutCount(invPreProductEntity.getOutCount() + count);
|
|
|
|
|
* } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
|
|
|
|
|
* invPreProductEntity.setInCount(invPreProductEntity.getInCount() + count);
|
|
|
|
|
* }
|
|
|
|
|
* if (erpOrderEntity.getPrice() != null) {
|
|
|
|
|
* invPreProductEntity.setPrice(erpOrderEntity.getPrice() + "");
|
|
|
|
|
* }
|
|
|
|
|
* invPreProductEntity.setUpdateTime(new Date());
|
|
|
|
|
* invPreInProductService.updateInvProduct(invPreProductEntity);
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
} else if (bussinessTypeEntity.isAdvanceType()) {//预入库,则转存预入库
|
|
|
|
|
InvProductEntity invPreProductEntity =
|
|
|
|
|
invPreProductService.selectByUuid(erpOrderEntity.getGoodsid(), erpOrderEntity.getBatchNo(), warehouseEntity.getSupId()
|
|
|
|
@ -166,10 +146,13 @@ public class InvProductsTrService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (orderEntity.isPreCheck()) {
|
|
|
|
|
|
|
|
|
|
//暂时不需要去计算库存
|
|
|
|
|
// int actCount = getActCount(warehouseEntity);
|
|
|
|
|
// int count = actCount * warehouseEntity.getCount();
|
|
|
|
|
// InvProductEntity preInvEntity = invPreInProductService.selectByUuid(erpOrderEntity.getGoodsid(), erpOrderEntity.getBatchNo(),
|
|
|
|
|
// warehouseEntity.getSupId(), null, null);
|
|
|
|
|
//
|
|
|
|
|
// if (preInvEntity != null) {
|
|
|
|
|
// if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
|
|
|
|
|
// preInvEntity.setOutCount(preInvEntity.getOutCount() + count);
|
|
|
|
@ -177,9 +160,10 @@ public class InvProductsTrService {
|
|
|
|
|
// if (erpOrderEntity.getPrice() != null) {
|
|
|
|
|
// preInvEntity.setPrice(erpOrderEntity.getPrice() + "");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// preInvEntity.setUpdateTime(new Date());
|
|
|
|
|
// invPreInProductService.updateInvProduct(preInvEntity);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -205,12 +189,6 @@ public class InvProductsTrService {
|
|
|
|
|
invProductDetailEntities = buildInvProductDetail(orderId, erpOrderEntity, orderEntity, 3);
|
|
|
|
|
} else {
|
|
|
|
|
invProductDetailEntities = buildInvProductDetail(orderId, erpOrderEntity, orderEntity, 2);
|
|
|
|
|
|
|
|
|
|
// if (orderEntity.isPreCheck()) {
|
|
|
|
|
//// insetInv(bussinessTypeEntity, invProductDetailEntities);//2.插入当前库存
|
|
|
|
|
//
|
|
|
|
|
// invPreInProductDetailService.insertInvProducts(invProductDetailEntities);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
if (invProductDetailEntities != null && invProductDetailEntities.size() > 0) {
|
|
|
|
|
mInvProductDetailEntities.addAll(invProductDetailEntities);
|
|
|
|
@ -222,7 +200,6 @@ public class InvProductsTrService {
|
|
|
|
|
//单据流转
|
|
|
|
|
List<BussinessChangeTypeEntity> bussinessChangeTypeEntitys = bussinessChangeTypeService.findByAction(bussinessLocalTypeEntity.getLocalAction());
|
|
|
|
|
if ((bussinessChangeTypeEntitys != null && bussinessChangeTypeEntitys.size() > 0) && bussinessLocalTypeEntity.isChangeEnable()) {
|
|
|
|
|
|
|
|
|
|
if (orderEntity.isOutChangeEnable()) {//是否缺量补单
|
|
|
|
|
//普通出库
|
|
|
|
|
if (ConstantType.TYPE_OUT.equals(bussinessTypeEntity.getMainAction()) && !bussinessTypeEntity.isAdvanceType()) {
|
|
|
|
@ -256,26 +233,12 @@ public class InvProductsTrService {
|
|
|
|
|
|
|
|
|
|
//普通出库补单-- //补采购入库,调拨入库,寄售转入
|
|
|
|
|
public void addUseOutOrder(OrderEntity orderEntity, List<InvProductDetailEntity> invProductDetailEntities, List<BussinessChangeTypeEntity> bussinessChangeTypeEntities) {
|
|
|
|
|
|
|
|
|
|
BussinessChangeTypeEntity advChangeTypeEntity = null;
|
|
|
|
|
BussinessChangeTypeEntity norChangeTypeEntity = null;
|
|
|
|
|
BussinessChangeTypeEntity outChangeTypeEntity = null;
|
|
|
|
|
BussinessChangeTypeEntity innorChangeTypeEntity = null;
|
|
|
|
|
for (BussinessChangeTypeEntity bussinessChangeTypeEntity : bussinessChangeTypeEntities) {
|
|
|
|
|
if (bussinessChangeTypeEntity.getChangeType() == ConstantStatus.ORDER_CHANGE_NORMAL_ADV_IN) {
|
|
|
|
|
advChangeTypeEntity = bussinessChangeTypeEntity;
|
|
|
|
|
} else if (bussinessChangeTypeEntity.getChangeType() == ConstantStatus.ORDER_CHANGE_NORMAL_IN) {
|
|
|
|
|
outChangeTypeEntity = bussinessChangeTypeEntity;
|
|
|
|
|
} else if (bussinessChangeTypeEntity.getChangeType() == ConstantStatus.ORDER_CHANGE_INNOR_NORMAL_IN) {
|
|
|
|
|
innorChangeTypeEntity = bussinessChangeTypeEntity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BussinessChangeTypeEntity bussinessChangeTypeEntity = bussinessChangeTypeEntity = bussinessChangeTypeEntities.get(0);
|
|
|
|
|
List<WarehouseEntity> warehouseEntities = codesService.findByReceiptId(orderEntity.getId());
|
|
|
|
|
List<WarehouseEntity> inList = new ArrayList<>();
|
|
|
|
|
List<WarehouseEntity> preiInList = new ArrayList<>();
|
|
|
|
|
//缺量补单时是否全量补单
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity1 = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
|
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("ullage_supplement_all");
|
|
|
|
|
if (bussinessTypeEntity1.isSupplementAll()) {
|
|
|
|
|
insetInv(bussinessTypeEntity1, invProductDetailEntities);//2.插入当前库存
|
|
|
|
|
WarehouseEntity warehouseEntity = warehouseEntities.get(0);
|
|
|
|
@ -286,7 +249,6 @@ public class InvProductsTrService {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (locWarehouseEntity.getLevel() > 1) {
|
|
|
|
|
norChangeTypeEntity = innorChangeTypeEntity;
|
|
|
|
|
InvWarehouseEntity pInWarehouseEntity = invWarehouseService.selectByCode(locWarehouseEntity.getPcode());
|
|
|
|
|
for (WarehouseEntity tempEntity : warehouseEntities) {
|
|
|
|
|
tempEntity.setFromCorp(pInWarehouseEntity.getName());
|
|
|
|
@ -294,7 +256,6 @@ public class InvProductsTrService {
|
|
|
|
|
inList.add(tempEntity);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
norChangeTypeEntity = outChangeTypeEntity;
|
|
|
|
|
BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(warehouseEntity.getSupId());
|
|
|
|
|
for (WarehouseEntity tempEntity : warehouseEntities) {
|
|
|
|
|
tempEntity.setFromCorpId(warehouseEntity.getSupId());
|
|
|
|
@ -325,7 +286,7 @@ public class InvProductsTrService {
|
|
|
|
|
* 《寄售转入库》往来单位:
|
|
|
|
|
* 单据类型的当前仓库(如果当前仓库有设置,则判断该当前仓库是否为1级库并且仓库类型=寄售,如果没设置,那么往来单位自动为默认寄售仓库),当前仓库:出库单据的当前仓库
|
|
|
|
|
*/
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(advChangeTypeEntity.getScAction());
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(bussinessChangeTypeEntity.getScAction());
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity;
|
|
|
|
|
if (!StrUtil.isEmpty(bussinessTypeEntity.getStorageCode())) {
|
|
|
|
|
invWarehouseEntity = invWarehouseService.selectByCode(bussinessTypeEntity.getStorageCode());
|
|
|
|
@ -337,13 +298,11 @@ public class InvProductsTrService {
|
|
|
|
|
} else
|
|
|
|
|
invWarehouseEntity = invWarehouseService.findDefault(true, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int invCount = getCountByOrder(null, warehouseEntity);
|
|
|
|
|
warehouseEntity.setFromCorpId(invWarehouseEntity.getCode());
|
|
|
|
|
warehouseEntity.setFromCorp(invWarehouseEntity.getName());
|
|
|
|
|
if (invCount > 0) {//仓库已存在该产品
|
|
|
|
|
if (count > invCount) { //当前数量>结余数量,说明该产品是无序列号或者是多级包装
|
|
|
|
|
// UdiEntity udiEntity = FilterUdiUtils.getUdi(warehouseEntity.getCode());
|
|
|
|
|
if (actCount > invCount) { //该产品实际数量大于结余数量,说明是多级包装,直接补
|
|
|
|
|
preiInList.add(warehouseEntity);
|
|
|
|
|
} else if (warehouseEntity.getSerialNo() == null) { //无序列号(多级包装无序列号的已在上一步被排除),补齐数量
|
|
|
|
@ -373,7 +332,6 @@ public class InvProductsTrService {
|
|
|
|
|
warehouseEntity.setFromCorpId(pInWarehouseEntity.getCode());
|
|
|
|
|
|
|
|
|
|
invCount = getCountByOrder(null, warehouseEntity);
|
|
|
|
|
norChangeTypeEntity = innorChangeTypeEntity;
|
|
|
|
|
} else { //补供应商入库
|
|
|
|
|
/**
|
|
|
|
|
* 供应商入库》往来单位:根据产品指定的供应商,当前仓库:出库单据的当前仓库;
|
|
|
|
@ -383,7 +341,6 @@ public class InvProductsTrService {
|
|
|
|
|
BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(warehouseEntity.getSupId());
|
|
|
|
|
warehouseEntity.setFromCorp(basicUnitMaintainEntity.getName());
|
|
|
|
|
invCount = getCountByOrder(null, warehouseEntity);
|
|
|
|
|
norChangeTypeEntity = outChangeTypeEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (invCount > 0) {//仓库已存在该产品
|
|
|
|
@ -411,12 +368,12 @@ public class InvProductsTrService {
|
|
|
|
|
|
|
|
|
|
if (inList.size() > 0) {
|
|
|
|
|
List<WarehouseEntity> temps = filterMapCodes(inList);
|
|
|
|
|
buildInOrder(norChangeTypeEntity, temps, orderEntity); //3.生成采购入库流转单据
|
|
|
|
|
buildInOrder(bussinessChangeTypeEntity, temps, orderEntity); //3.生成采购入库流转单据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (preiInList.size() > 0) {
|
|
|
|
|
List<WarehouseEntity> temps1 = filterMapCodes(preiInList);
|
|
|
|
|
buildNorPreInOrder(advChangeTypeEntity, temps1, orderEntity); //3.补寄售转入
|
|
|
|
|
buildNorPreInOrder(bussinessChangeTypeEntity, temps1, orderEntity); //3.补寄售转入
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -646,7 +603,6 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setFromCorpId(null);
|
|
|
|
|
outOrder.setLocStorageCode(orderEntity.getLocStorageCode());
|
|
|
|
|
outOrder.setInvStorageCode(orderEntity.getInvStorageCode());
|
|
|
|
|
|
|
|
|
|
//互填单号
|
|
|
|
|
orderEntity.setUllageSupNo(outOrder.getId());
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
@ -712,15 +668,13 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
outOrder.setFromCorpId(corpName);
|
|
|
|
|
outOrder.setFromCorp(temps.get(0).getFromCorp());
|
|
|
|
|
|
|
|
|
|
// BussinessTypeEntity originBT = bussinessTypeService.findBTByAction(orderEntity.getAction());
|
|
|
|
|
if (StrUtil.isNotEmpty(bussinessChangeTypeEntity.getDefaultSubInv())) {
|
|
|
|
|
outOrder.setFromSubInvCode(bussinessChangeTypeEntity.getDefaultSubInv());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outOrder.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
|
outOrder.setLocStorageCode(orderEntity.getLocStorageCode());
|
|
|
|
|
outOrder.setInvStorageCode(orderEntity.getInvStorageCode());
|
|
|
|
|
outOrder.setInvStorageCode(orderEntity.getLocStorageCode());
|
|
|
|
|
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("additional_auto_submit");
|
|
|
|
|
if ("1".equals(systemParamConfigEntity.getParamValue())) {
|
|
|
|
@ -963,6 +917,7 @@ public class InvProductsTrService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void insetInvSingle(boolean isPre, InvProductDetailEntity invProductDetailEntity) {
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = new ArrayList<>();
|
|
|
|
|
invProductDetailEntities.add(invProductDetailEntity);
|
|
|
|
|