|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.admin.constant.Constant;
|
|
|
|
@ -189,7 +190,10 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
} else {
|
|
|
|
|
//审核通过
|
|
|
|
|
//根据单据详情生成相关单据
|
|
|
|
|
countOrderTransfer(invCountOrder);
|
|
|
|
|
log.info("单据审核通过,开始生成扫码单据");
|
|
|
|
|
ThreadUtil.execAsync(() -> {
|
|
|
|
|
countOrderTransfer(invCountOrder);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
invCountOrderDao.updateByPrimaryKey(invCountOrder);
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
@ -273,24 +277,44 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
codesRequest.setProductId(invCountOrderDetail.getProductId());
|
|
|
|
|
codesRequest.setBatchNo(invCountOrderDetail.getBatchNo());
|
|
|
|
|
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);
|
|
|
|
|
List<String> invProductCodes = invProductDetailEntities.stream().map(InvProductDetailEntity::getOriginCode).collect(Collectors.toList());
|
|
|
|
|
List<String> lossCodes = CollUtil.subtractToList(invProductCodes, countCodesList);
|
|
|
|
|
if (CollUtil.isNotEmpty(countCodesList) && CollUtil.isEmpty(lossCodes)) {
|
|
|
|
|
//盘点的码不为空,但是盘点数量和库存数量不一样,比对差集结果为空,说明是同一个条码,数量不同,直接根据盘亏数量计算生成一个扫码单据的码明细
|
|
|
|
|
//生成码详情
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, invProductDetailEntities.get(0).getCode(), invProductDetailEntities.get(0).getProductIdFk());
|
|
|
|
|
//判断此条码,是否有批次号和序列号
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(invProductDetailEntities.get(0).getOriginCode());
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getLossNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
|
|
|
|
|
//设置供应商信息
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
outOrderCodes.add(warehouseEntity);
|
|
|
|
|
} else {
|
|
|
|
|
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())) || (StrUtil.isBlank(udi.getSerialNo()) && StrUtil.isNotBlank(udi.getBatchNo()))) {
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getLossNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置供应商信息
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
outOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置供应商信息
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
outOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -316,22 +340,41 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
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);
|
|
|
|
|
List<String> profitCodes = CollUtil.subtractToList(countCodesList, invProductCodeList); //计算盘盈的条码
|
|
|
|
|
if (CollUtil.isNotEmpty(invProductCodeList) && CollUtil.isEmpty(profitCodes)) {
|
|
|
|
|
/**
|
|
|
|
|
* 盘点条码不为空,且库存条码也不为空,但是计算的条码差集为空
|
|
|
|
|
* 说明盘点的条码和库存的条码是相同的条码,直接根据盘盈数量计算出扫码数量,生成一个条码即可
|
|
|
|
|
*/
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, countCodesList.get(0), invCountOrderDetail.getProductId());
|
|
|
|
|
//判断此条码,是否有批次号和序列号
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(countCodesList.get(0));
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
inOrderCodes.add(warehouseEntity);
|
|
|
|
|
} else {
|
|
|
|
|
for (String code : profitCodes) {
|
|
|
|
|
if (!verifyCodeExist(inOrderCodes, code)) {
|
|
|
|
|
//生成码详情
|
|
|
|
|
WarehouseEntity warehouseEntity = buildWarehouse(invCountOrder, code, invCountOrderDetail.getProductId());
|
|
|
|
|
//判断此条码,是否有批次号和序列号
|
|
|
|
|
UdiEntity udi = FilterUdiUtils.getUdi(code);
|
|
|
|
|
if ((StrUtil.isBlank(udi.getBatchNo()) && StrUtil.isBlank(udi.getSerialNo())) || (StrUtil.isBlank(udi.getSerialNo()) && StrUtil.isNotBlank(udi.getBatchNo()))) {
|
|
|
|
|
//修改码数量
|
|
|
|
|
int actCount = invCountCodesService.getActCount(udi.getUdi());
|
|
|
|
|
//使用此盘点单据详情的盘亏数量 / 实际数量,计算得出扫码数量
|
|
|
|
|
int codeNum = invCountOrderDetail.getProfitNum() / actCount;
|
|
|
|
|
warehouseEntity.setCount(codeNum);
|
|
|
|
|
warehouseEntity.setReCount(codeNum);
|
|
|
|
|
}
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
inOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
setSupInfo(warehouseEntity);
|
|
|
|
|
inOrderCodes.add(warehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -393,7 +436,7 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
if (StrUtil.isNotEmpty(supId)) {
|
|
|
|
|
warehouseEntity.setSupId(supId);
|
|
|
|
|
//查询供应商名称
|
|
|
|
|
String name = unitMaintainDao.selectNameByErpId(supId);
|
|
|
|
|
String name = unitMaintainDao.selectNameByErpId(supId);
|
|
|
|
|
warehouseEntity.setSupName(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -406,9 +449,10 @@ public class InvCountOrderServiceImpl implements InvCountOrderService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean verifyCodeExist(List<WarehouseEntity> codes, String code) {
|
|
|
|
|
List<String> codesList = codes.stream().map(WarehouseEntity::getCode).collect(Collectors.toList());
|
|
|
|
|
if (codesList.contains(code)) {
|
|
|
|
|
return true;
|
|
|
|
|
for (WarehouseEntity warehouseEntity : codes) {
|
|
|
|
|
if (warehouseEntity.getCode().equals(code)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|