|
|
|
@ -167,23 +167,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
//平衡
|
|
|
|
|
invCountOrderDetail.setStatus(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询此产品的条码列表,判断此产品在库存中是多还是少
|
|
|
|
|
List<InvCountCodes> codesList = invCountCodesDao.selectByOrderIdAndProductId(invCountOrderDetail.getOrderIdFk(), invCountOrderDetail.getProductId());
|
|
|
|
|
//判断盘点的码中是否有次产品的码
|
|
|
|
|
if (CollUtil.isNotEmpty(codesList)) {
|
|
|
|
|
//查询库存中此产品的码数据,用来判断盘单据条码是多码还是少码
|
|
|
|
|
List<String> invDetailCodes = invProductDetailDao.selectCodeByInvCodeAndProductId(invCountOrder.getInvStorageCode(), invCountOrder.getInvWarehouseCode(), invCountOrder.getInvSpaceCode(), invCountOrderDetail.getProductId());
|
|
|
|
|
for (InvCountCodes invCountCodes : codesList) {
|
|
|
|
|
//查询此条码在库存中是否存在
|
|
|
|
|
boolean contains = invDetailCodes.contains(invCountCodes.getCode());
|
|
|
|
|
if (!contains) {
|
|
|
|
|
invCountCodes.setStatus(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//批量更新条码信息
|
|
|
|
|
invCountCodesDao.updateBatch(codesList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//更新单据信息
|
|
|
|
|
invCountOrderDao.updateByPrimaryKey(invCountOrder);
|
|
|
|
@ -203,8 +186,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
//审核不通过
|
|
|
|
|
//查询盘点单据详情,清空盘盈/盘亏数值
|
|
|
|
|
invCountOrderDetailDao.resetCountFiledValue(invCountOrder.getOrderId());
|
|
|
|
|
//清空条码的状态
|
|
|
|
|
invCountCodesDao.resetCountFiledValue(invCountOrder.getOrderId());
|
|
|
|
|
} else {
|
|
|
|
|
//审核通过
|
|
|
|
|
//根据单据详情生成相关单据
|
|
|
|
@ -236,8 +217,6 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 盘点单据转扫码单
|
|
|
|
|
*
|
|
|
|
|
* @param invCountOrder
|
|
|
|
|
*/
|
|
|
|
|
private void countOrderTransfer(InvCountOrder invCountOrder) {
|
|
|
|
|
List<InvCountSettingEntity> list = invCountSettingDao.filterList(null);
|
|
|
|
@ -250,28 +229,43 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
List<WarehouseEntity> inOrderCodes = new ArrayList<>();
|
|
|
|
|
List<WarehouseEntity> outOrderCodes = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成盘盈和盘亏单据逻辑
|
|
|
|
|
* 盘盈单据:1、找出盘点单据码详情比库存码详情多的产品
|
|
|
|
|
* 2、判断条码是否包含批次号和序列号,如果不包含,根据 盘盈数量 / 实际数量 = 多出的条码数量 ,计算出盘盈单据此条码的扫码数量
|
|
|
|
|
* 3、生成条码,保存单据
|
|
|
|
|
*
|
|
|
|
|
* 盘亏单据:1、找出库存有,而盘点不存在的条码
|
|
|
|
|
* 2、判断此库存详情是否包含批次号,如果不包含,盘亏数量 / 实际数量 = 少的条码数量,计算出盘亏单据扫码数量
|
|
|
|
|
* 3、生成条码,保存单据
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//构造库存详情查询参数
|
|
|
|
|
FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
|
invProductDetailRequest.setInvStorageCode(invCountOrder.getInvStorageCode());
|
|
|
|
|
invProductDetailRequest.setInvWarehouseCode(invCountOrder.getInvWarehouseCode());
|
|
|
|
|
//库存早于或等于盘点时间的库存数据,锁库存
|
|
|
|
|
invProductDetailRequest.setUpdateTime(invCountOrder.getCreateTime());
|
|
|
|
|
|
|
|
|
|
if (invCountOrder.getCountType() == 1) {
|
|
|
|
|
//按照货位盘点,查询库存详情添加货位条件
|
|
|
|
|
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FilterInvCountOrderDetailRequest detailRequest = new FilterInvCountOrderDetailRequest();
|
|
|
|
|
detailRequest.setOrderIdFk(invCountOrder.getOrderId());
|
|
|
|
|
//查询亏损单据详情
|
|
|
|
|
detailRequest.setStatus(0);
|
|
|
|
|
List<InvCountOrderDetail> detailList = invCountOrderDetailDao.selectDetailList(detailRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(detailList)) {
|
|
|
|
|
List<InvCountOrderDetail> lossDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(lossDetailList)) {
|
|
|
|
|
log.info("开始生成盘亏单据码明细");
|
|
|
|
|
log.info("查询盘亏产品码详情");
|
|
|
|
|
FilterInvProductDetailRequest invProductDetailRequest = new FilterInvProductDetailRequest();
|
|
|
|
|
invProductDetailRequest.setInvStorageCode(invCountOrder.getInvStorageCode());
|
|
|
|
|
invProductDetailRequest.setInvWarehouseCode(invCountOrder.getInvWarehouseCode());
|
|
|
|
|
if (invCountOrder.getCountType() == 1) {
|
|
|
|
|
//按照货位盘点,查询库存详情添加货位条件
|
|
|
|
|
invProductDetailRequest.setInvSpaceCode(invCountOrder.getInvSpaceCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (InvCountOrderDetail invCountOrderDetail : detailList) {
|
|
|
|
|
for (InvCountOrderDetail invCountOrderDetail : lossDetailList) {
|
|
|
|
|
//查询库存详情
|
|
|
|
|
invProductDetailRequest.setProductIdFk(invCountOrderDetail.getProductId());
|
|
|
|
|
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
|
|
|
|
|
//库存早于或等于盘点时间的库存数据,锁库存
|
|
|
|
|
invProductDetailRequest.setUpdateTime(invCountOrder.getCreateTime());
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(invProductDetailRequest);
|
|
|
|
|
//查询盘点码明细
|
|
|
|
|
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
|
|
|
|
@ -281,33 +275,65 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
|
|
|
|
|
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
|
|
|
|
|
if (!countCodesList.contains(invProductDetailEntity.getOriginCode()) && !verifyCodeExist(outOrderCodes, invProductDetailEntity.getCode())) {
|
|
|
|
|
//生成码详情
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, invProductDetailEntity.getCode(), invProductDetailEntity.getProductIdFk());
|
|
|
|
|
//判断此条码,是否有批次号和序列号
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(invProductDetailEntity.getOriginCode());
|
|
|
|
|
if (StrUtil.isBlank(udi.getBatchNo()) || StrUtil.isBlank(udi.getSerialNo())) {
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getLossNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
}
|
|
|
|
|
outOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("盘亏单据码明细生成完毕");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询盘盈的条码明细
|
|
|
|
|
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
|
|
|
|
|
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
|
|
|
|
|
//码状态标记为多码的数据
|
|
|
|
|
codesRequest.setStatus(1);
|
|
|
|
|
List<InvCountCodes> invCountCodesList = invCountCodesDao.filterList(codesRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(invCountCodesList)) {
|
|
|
|
|
//生成盘盈单据的条码
|
|
|
|
|
//查询盘盈的单据详情
|
|
|
|
|
detailRequest.setStatus(1);
|
|
|
|
|
List<InvCountOrderDetail> profitDetailList = invCountOrderDetailDao.selectDetailList(detailRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(profitDetailList)) {
|
|
|
|
|
log.info("开始生成盘盈单据码明细");
|
|
|
|
|
for (InvCountCodes invCountCodes : invCountCodesList) {
|
|
|
|
|
if (!verifyCodeExist(inOrderCodes, invCountCodes.getCode())) {
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, invCountCodes.getCode(), invCountCodes.getProductId());
|
|
|
|
|
inOrderCodes.add(warehouseEntity);
|
|
|
|
|
//查询盘盈产品的库存详情
|
|
|
|
|
for (InvCountOrderDetail invCountOrderDetail : profitDetailList) {
|
|
|
|
|
//查询库存详情
|
|
|
|
|
invProductDetailRequest.setProductIdFk(invCountOrderDetail.getProductId());
|
|
|
|
|
invProductDetailRequest.setBatchNo(invCountOrderDetail.getBatchNo());
|
|
|
|
|
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.filterInvProductDetail(invProductDetailRequest);
|
|
|
|
|
//查询盘点码明细
|
|
|
|
|
FilterInvCountCodesRequest codesRequest = new FilterInvCountCodesRequest();
|
|
|
|
|
codesRequest.setOrderIdFk(invCountOrder.getOrderId());
|
|
|
|
|
codesRequest.setProductId(invCountOrderDetail.getProductId());
|
|
|
|
|
codesRequest.setBatchNo(invCountOrderDetail.getBatchNo());
|
|
|
|
|
List<String> countCodesList = invCountCodesDao.selectCodes(codesRequest);
|
|
|
|
|
List<String> invProductCodeList = invProductDetailEntities.stream().map(InvProductDetailEntity::getOriginCode).collect(Collectors.toList());
|
|
|
|
|
for (String code : countCodesList) {
|
|
|
|
|
if (!invProductCodeList.contains(code) && !verifyCodeExist(inOrderCodes, code)) {
|
|
|
|
|
//生成码详情
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, code, invCountOrderDetail.getProductId());
|
|
|
|
|
//判断此条码,是否有批次号和序列号
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(code);
|
|
|
|
|
if (StrUtil.isBlank(udi.getBatchNo()) || StrUtil.isBlank(udi.getSerialNo())) {
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
}
|
|
|
|
|
inOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info("盘盈单据码明细生成完毕");
|
|
|
|
|
log.info("盘盈单据码详情生成完毕");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvCountSettingEntity invCountSettingEntity = list.get(0);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(inOrderCodes)) {
|
|
|
|
|