|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
package com.glxp.sale.admin.thread;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.glxp.sale.admin.constant.Constant;
|
|
|
|
|
import com.glxp.sale.admin.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.sale.admin.constant.ConstantType;
|
|
|
|
|
import com.glxp.sale.admin.entity.basic.*;
|
|
|
|
|
import com.glxp.sale.admin.entity.info.CompanyEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.inout.*;
|
|
|
|
|
import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.inventory.InvProductEntity;
|
|
|
|
@ -14,27 +12,19 @@ import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.udid.UdiEntity;
|
|
|
|
|
import com.glxp.sale.admin.req.basic.FilterUdiInfoRequest;
|
|
|
|
|
import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest;
|
|
|
|
|
import com.glxp.sale.admin.res.basic.BussinessTypResponse;
|
|
|
|
|
import com.glxp.sale.admin.res.basic.UdiRelevanceResponse;
|
|
|
|
|
import com.glxp.sale.admin.res.inventory.InvProductDetailJoinResponse;
|
|
|
|
|
import com.glxp.sale.admin.service.basic.*;
|
|
|
|
|
import com.glxp.sale.admin.service.info.CompanyService;
|
|
|
|
|
import com.glxp.sale.admin.service.inout.*;
|
|
|
|
|
import com.glxp.sale.admin.service.inventory.*;
|
|
|
|
|
import com.glxp.sale.admin.service.param.SystemParamConfigService;
|
|
|
|
|
import com.glxp.sale.admin.util.CustomUtil;
|
|
|
|
|
import com.glxp.sale.admin.util.DateUtil;
|
|
|
|
|
import com.glxp.sale.admin.util.FilterUdiUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.apache.regexp.RE;
|
|
|
|
|
import com.glxp.sale.admin.util.*;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class InvProductsTrService {
|
|
|
|
@ -68,18 +58,14 @@ public class InvProductsTrService {
|
|
|
|
|
private BussinessChangeTypeService bussinessChangeTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicUnitMaintainService basicUnitMaintainService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
@Lazy
|
|
|
|
|
private IoTransInoutService ioTransInoutService;
|
|
|
|
|
@Resource
|
|
|
|
|
CompanyService companyService;
|
|
|
|
|
@Resource
|
|
|
|
|
SystemParamConfigService systemParamConfigService;
|
|
|
|
|
@Resource
|
|
|
|
|
IOOrderStatusService ioOrderStatusService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
@Resource
|
|
|
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
|
public void genInvProducts(String orderId) {
|
|
|
|
@ -178,26 +164,19 @@ public class InvProductsTrService {
|
|
|
|
|
if (orderEntity.isOutChangeEnable()) {//是否缺量补单
|
|
|
|
|
//普通出库
|
|
|
|
|
if (ConstantType.TYPE_OUT.equals(bussinessTypeEntity.getMainAction()) && !bussinessTypeEntity.isAdvanceType()) {
|
|
|
|
|
//补采购入库或寄售转入单
|
|
|
|
|
// List<WarehouseEntity> datas = addOutOrder(orderEntity, mInvProductDetailEntities);//1.先计算现有库存,
|
|
|
|
|
// List<WarehouseEntity> temps = filterMapCodes(datas);
|
|
|
|
|
|
|
|
|
|
addUseOutOrder(orderEntity, mInvProductDetailEntities, bussinessChangeTypeEntitys);
|
|
|
|
|
|
|
|
|
|
} else if (ConstantType.TYPE_PUT.equals(bussinessTypeEntity.getMainAction()) && !bussinessTypeEntity.isAdvanceType())
|
|
|
|
|
//普通入库补单
|
|
|
|
|
{
|
|
|
|
|
BussinessChangeTypeEntity bussinessChangeTypeEntity = bussinessChangeTypeEntitys.get(0);
|
|
|
|
|
List<WarehouseEntity> datas = addPutOrder(orderEntity, mInvProductDetailEntities);
|
|
|
|
|
List<WarehouseEntity> temps = filterMapCodes(datas);
|
|
|
|
|
// insetInv(bussinessTypeEntity.isAdvanceType(), mInvProductDetailEntities);//2.插入当前库存
|
|
|
|
|
buildPreOutOrder(bussinessChangeTypeEntity, temps, orderEntity); //3.生成流转单据
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(bussinessTypeEntity.getMainAction()) && bussinessTypeEntity.isAdvanceType()) {
|
|
|
|
|
//寄售出库补单
|
|
|
|
|
BussinessChangeTypeEntity bussinessChangeTypeEntity = bussinessChangeTypeEntitys.get(0);
|
|
|
|
|
List<WarehouseEntity> datas = addPreOutOrder(orderEntity, mInvProductDetailEntities);
|
|
|
|
|
List<WarehouseEntity> temps = filterMapCodes(datas);
|
|
|
|
|
// insetInv(bussinessTypeEntity.isAdvanceType(), mInvProductDetailEntities);//2.插入当前库存
|
|
|
|
|
buildPreInOrder(bussinessChangeTypeEntity, temps, orderEntity); //3.生成流转单据
|
|
|
|
|
} else {
|
|
|
|
|
insetInv(bussinessTypeEntity.isAdvanceType(), mInvProductDetailEntities);//2.插入当前库存
|
|
|
|
@ -213,7 +192,7 @@ public class InvProductsTrService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//普通出库补单-- //补采购入库或寄售转入单
|
|
|
|
|
//普通出库补单-- //补采购入库,调拨入库,寄售转入
|
|
|
|
|
public void addUseOutOrder(OrderEntity orderEntity, List<InvProductDetailEntity> invProductDetailEntities, List<BussinessChangeTypeEntity> bussinessChangeTypeEntities) {
|
|
|
|
|
|
|
|
|
|
BussinessChangeTypeEntity advChangeTypeEntity = null;
|
|
|
|
@ -235,9 +214,33 @@ public class InvProductsTrService {
|
|
|
|
|
//缺量补单时是否全量补单
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("ullage_supplement_all");
|
|
|
|
|
if (systemParamConfigEntity != null && systemParamConfigEntity.getParamValue().equals("1")) {
|
|
|
|
|
for (WarehouseEntity warehouseEntity : warehouseEntities) {
|
|
|
|
|
inList.add(warehouseEntity);
|
|
|
|
|
WarehouseEntity warehouseEntity = warehouseEntities.get(0);
|
|
|
|
|
InvWarehouseEntity locWarehouseEntity = invWarehouseService.selectByCode(warehouseEntity.getLocStorageCode());
|
|
|
|
|
if (locWarehouseEntity.getLevel() == 1 && isAdavnce(warehouseEntity)) {//补寄售转入
|
|
|
|
|
for (WarehouseEntity tempEntity : warehouseEntities) {
|
|
|
|
|
preiInList.add(tempEntity);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (locWarehouseEntity.getLevel() > 1) {
|
|
|
|
|
norChangeTypeEntity = innorChangeTypeEntity;
|
|
|
|
|
InvWarehouseEntity pInWarehouseEntity = invWarehouseService.selectByCode(locWarehouseEntity.getPcode());
|
|
|
|
|
for (WarehouseEntity tempEntity : warehouseEntities) {
|
|
|
|
|
tempEntity.setFromCorp(pInWarehouseEntity.getName());
|
|
|
|
|
tempEntity.setFromCorpId(pInWarehouseEntity.getCode());
|
|
|
|
|
inList.add(tempEntity);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
norChangeTypeEntity = outChangeTypeEntity;
|
|
|
|
|
BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(warehouseEntity.getSupId());
|
|
|
|
|
for (WarehouseEntity tempEntity : warehouseEntities) {
|
|
|
|
|
tempEntity.setFromCorpId(warehouseEntity.getSupId());
|
|
|
|
|
tempEntity.setFromCorp(basicUnitMaintainEntity.getName());
|
|
|
|
|
inList.add(tempEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
for (WarehouseEntity warehouseEntity : warehouseEntities) {
|
|
|
|
|
/**
|
|
|
|
@ -248,13 +251,10 @@ public class InvProductsTrService {
|
|
|
|
|
* {可能需要补录的入库单据有一种:《调拨入库》}
|
|
|
|
|
*/
|
|
|
|
|
InvWarehouseEntity locWarehouseEntity = invWarehouseService.selectByCode(warehouseEntity.getLocStorageCode());
|
|
|
|
|
|
|
|
|
|
if (locWarehouseEntity.getLevel() == 1 && isAdavnce(warehouseEntity)) {//补寄售转入
|
|
|
|
|
|
|
|
|
|
//获取当前条码实际数量
|
|
|
|
|
int actCount = getActCount(warehouseEntity);
|
|
|
|
|
int count = 0;
|
|
|
|
|
UdiInfoEntity udiInfoEntity = getMinDi(warehouseEntity);
|
|
|
|
|
String code = warehouseEntity.getCode();
|
|
|
|
|
count = actCount * warehouseEntity.getCount();
|
|
|
|
|
/**
|
|
|
|
@ -289,7 +289,6 @@ public class InvProductsTrService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else { //结余数量《=0直接补
|
|
|
|
|
// warehouseEntity.setCount(count);
|
|
|
|
|
preiInList.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = filterInvByCode(invProductDetailEntities, warehouseEntity.getCode());
|
|
|
|
@ -298,18 +297,8 @@ public class InvProductsTrService {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
int actCount = getActCount(warehouseEntity);
|
|
|
|
|
UdiInfoEntity udiInfoEntity = getMinDi(warehouseEntity);
|
|
|
|
|
String code = warehouseEntity.getCode();
|
|
|
|
|
int count = actCount * warehouseEntity.getCount();
|
|
|
|
|
// if (udiInfoEntity.getDiType() == ConstantStatus.DITYPE_PACK || udiInfoEntity.getDiType() == ConstantStatus.DITYPE_SYDY
|
|
|
|
|
// || (udiInfoEntity.getSjcpbm() != null && !"".equals(udiInfoEntity.getSjcpbm()))) {
|
|
|
|
|
// warehouseEntity.setNameCode(udiInfoEntity.getNameCode());
|
|
|
|
|
// code = FilterUdiUtils.transGlxpNoSerStr(warehouseEntity);
|
|
|
|
|
// count = actCount * warehouseEntity.getCount();
|
|
|
|
|
// } else {
|
|
|
|
|
// count = warehouseEntity.getCount();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
int invCount = 0;
|
|
|
|
|
if (locWarehouseEntity.getLevel() > 1) {//补调拨入库
|
|
|
|
|
/**
|
|
|
|
@ -320,10 +309,6 @@ public class InvProductsTrService {
|
|
|
|
|
warehouseEntity.setFromCorpId(pInWarehouseEntity.getCode());
|
|
|
|
|
|
|
|
|
|
invCount = getCountByOrder(null, warehouseEntity);
|
|
|
|
|
// invCount = getCountByOrder(null, warehouseEntity.getCode(), warehouseEntity.getSupId(), locWarehouseEntity.getPcode());
|
|
|
|
|
// if (invCount <= 0) {
|
|
|
|
|
// invCount = getCountByOrder(null, code, warehouseEntity.getSupId(), locWarehouseEntity.getPcode());
|
|
|
|
|
// }
|
|
|
|
|
norChangeTypeEntity = innorChangeTypeEntity;
|
|
|
|
|
} else { //补供应商入库
|
|
|
|
|
/**
|
|
|
|
@ -334,11 +319,6 @@ public class InvProductsTrService {
|
|
|
|
|
BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(warehouseEntity.getSupId());
|
|
|
|
|
warehouseEntity.setFromCorp(basicUnitMaintainEntity.getName());
|
|
|
|
|
invCount = getCountByOrder(null, warehouseEntity);
|
|
|
|
|
|
|
|
|
|
// invCount = getCountByOrder(null, warehouseEntity.getCode(), warehouseEntity.getSupId(), null);
|
|
|
|
|
// if (invCount <= 0) {
|
|
|
|
|
// invCount = getCountByOrder(null, code, warehouseEntity.getSupId(), null);
|
|
|
|
|
// }
|
|
|
|
|
norChangeTypeEntity = outChangeTypeEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -354,19 +334,8 @@ public class InvProductsTrService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else { //结余数量《=0直接补
|
|
|
|
|
// warehouseEntity.setCount(count);
|
|
|
|
|
inList.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
// if (invCount > 0) {
|
|
|
|
|
// if (count > invCount) {
|
|
|
|
|
// int lea = count - invCount;
|
|
|
|
|
// warehouseEntity.setCount(lea / getActCount(warehouseEntity));
|
|
|
|
|
// inList.add(warehouseEntity);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// warehouseEntity.setCount(count);
|
|
|
|
|
// inList.add(warehouseEntity);
|
|
|
|
|
// }
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = filterInvByCode(invProductDetailEntities, warehouseEntity.getCode());
|
|
|
|
|
insetInvSingle(false, invProductDetailEntity);
|
|
|
|
|
warehouseEntity.setCode(code);
|
|
|
|
@ -491,11 +460,12 @@ public class InvProductsTrService {
|
|
|
|
|
} else {
|
|
|
|
|
outOrder.setStatus(ConstantStatus.ORDER_STATUS_ADDITIONAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outOrder.setContrastStatus(ConstantStatus.ORDER_CHECK_UN);
|
|
|
|
|
outOrder.setErpFk(null);
|
|
|
|
|
outOrder.setCustomerId(Constant.SYSTEM_CUSTOMER_ID);
|
|
|
|
|
outOrder.setId("SM" + CustomUtil.getId());
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(bussinessChangeTypeEntity.getScAction());
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + MyStrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
outOrder.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
|
outOrder.setFromCorp(invWarehouseEntity.getName());
|
|
|
|
|
outOrder.setFromCorpId(invWarehouseEntity.getCode());
|
|
|
|
@ -541,6 +511,9 @@ public class InvProductsTrService {
|
|
|
|
|
unkonwCorpList.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(bussinessChangeTypeEntity.getScAction());
|
|
|
|
|
|
|
|
|
|
//有供应商生成采购入库单据
|
|
|
|
|
for (String corpName : filterSupMaps.keySet()) {
|
|
|
|
|
List<WarehouseEntity> temps;
|
|
|
|
@ -561,7 +534,8 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setContrastStatus(ConstantStatus.ORDER_CHECK_UN);
|
|
|
|
|
outOrder.setErpFk(null);
|
|
|
|
|
outOrder.setFromType(ConstantStatus.FROM_CHANGE);
|
|
|
|
|
outOrder.setId("SM" + CustomUtil.getId());
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + MyStrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(corpName);
|
|
|
|
|
outOrder.setFromCorp(basicUnitMaintainEntity.getName());
|
|
|
|
|
outOrder.setFromCorpId(corpName);
|
|
|
|
@ -605,7 +579,8 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setContrastStatus(ConstantStatus.ORDER_CHECK_UN);
|
|
|
|
|
outOrder.setRemark("未选择供应商");
|
|
|
|
|
outOrder.setErpFk(null);
|
|
|
|
|
outOrder.setId("SM" + CustomUtil.getId());
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + MyStrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
outOrder.setFromCorp(null);
|
|
|
|
|
outOrder.setCustomerId(Constant.SYSTEM_CUSTOMER_ID);
|
|
|
|
|
outOrder.setFromCorpId(null);
|
|
|
|
@ -653,7 +628,7 @@ public class InvProductsTrService {
|
|
|
|
|
} else
|
|
|
|
|
unkonwCorpList.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(bussinessChangeTypeEntity.getScAction());
|
|
|
|
|
//根据往来单位生成入库单
|
|
|
|
|
for (String corpName : filterSupMaps.keySet()) {
|
|
|
|
|
List<WarehouseEntity> temps;
|
|
|
|
@ -668,7 +643,8 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setCustomerId(Constant.SYSTEM_CUSTOMER_ID);
|
|
|
|
|
outOrder.setErpFk(null);
|
|
|
|
|
outOrder.setFromType(ConstantStatus.FROM_CHANGE);
|
|
|
|
|
outOrder.setId("SM" + CustomUtil.getId());
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + MyStrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
outOrder.setFromCorpId(corpName);
|
|
|
|
|
outOrder.setFromCorp(temps.get(0).getFromCorp());
|
|
|
|
|
outOrder.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
@ -725,7 +701,7 @@ public class InvProductsTrService {
|
|
|
|
|
} else
|
|
|
|
|
unkonwCorpList.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(bussinessChangeTypeEntity.getScAction());
|
|
|
|
|
//有供应商生成采购入库单据
|
|
|
|
|
for (String corpName : filterSupMaps.keySet()) {
|
|
|
|
|
List<WarehouseEntity> temps;
|
|
|
|
@ -748,10 +724,8 @@ public class InvProductsTrService {
|
|
|
|
|
outOrder.setLocStorageCode(orderEntity.getLocStorageCode());
|
|
|
|
|
outOrder.setErpFk(null);
|
|
|
|
|
outOrder.setFromType(ConstantStatus.FROM_CHANGE);
|
|
|
|
|
outOrder.setId("SM" + CustomUtil.getId());
|
|
|
|
|
// BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByErpId(corpName);
|
|
|
|
|
// outOrder.setFromCorp(basicUnitMaintainEntity.getName());
|
|
|
|
|
// outOrder.setFromCorpId(corpName);
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + MyStrUtil.trim(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
outOrder.setId(orderNo);
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("additional_auto_submit");
|
|
|
|
|
if ("1".equals(systemParamConfigEntity.getParamValue())) {
|
|
|
|
|
outOrder.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
|
|
|
|
|