1.修复生成库存数据错误问题

master
x_z 3 years ago
parent 02a30d7e2c
commit 1ac50c2c5f

@ -170,7 +170,7 @@ public class UdiTraceController {
if (udiInfoEntities != null) { if (udiInfoEntities != null) {
if (udiInfoEntities.size() > 1) {//多级包装,查所有 if (udiInfoEntities.size() > 1) {//多级包装,查所有
FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest();
filterInvProductDetailRequest.setProductIdFk(udiInfoEntity.getUuid()); filterInvProductDetailRequest.setProductIdFk(String.valueOf(udiInfoEntity.getId()));
filterInvProductDetailRequest.setBatchNo(udiEntity.getBatchNo()); filterInvProductDetailRequest.setBatchNo(udiEntity.getBatchNo());
if (warehouseQueryRequest.getCustomerId() != null) { if (warehouseQueryRequest.getCustomerId() != null) {
filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + ""); filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + "");

@ -6,14 +6,47 @@ import lombok.Data;
@Data @Data
public class WarehouseQueryRequest extends ListPageRequest { public class WarehouseQueryRequest extends ListPageRequest {
/**
*
*/
private String corpOrderId; private String corpOrderId;
/**
*
*/
private String code; private String code;
/**
* DI
*/
private String udi; private String udi;
/**
*
*/
private String batchNo; private String batchNo;
/**
*
*/
private String orderId; private String orderId;
/**
* DI
*/
private String nameCode; private String nameCode;
private String lastId; private String lastId;
/**
* ID
*/
private String customerId; private String customerId;
private Integer filterType; private Integer filterType;
/**
* ID
*/
private String relId;
} }

@ -45,7 +45,7 @@ public class InvProductService {
return invProductDao.selectList(wrapper); return invProductDao.selectList(wrapper);
} }
public InvProductEntity selectByUuid(String relIdFk, String batchNo, String customerId, String locStorageCode) { public InvProductEntity selectByRelIdFk(String relIdFk, String batchNo, String customerId, String locStorageCode) {
QueryWrapper<InvProductEntity> wrapper = new QueryWrapper<>(); QueryWrapper<InvProductEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(relIdFk), "relIdFk", relIdFk) wrapper.eq(StrUtil.isNotBlank(relIdFk), "relIdFk", relIdFk)
.eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo) .eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo)

@ -57,6 +57,7 @@ public class WarehouseService {
private QueryWrapper<WarehouseEntity> buildCodesQueryWrapper(WarehouseQueryRequest warehouseQueryRequest) { private QueryWrapper<WarehouseEntity> buildCodesQueryWrapper(WarehouseQueryRequest warehouseQueryRequest) {
QueryWrapper<WarehouseEntity> wrapper = new QueryWrapper<>(); QueryWrapper<WarehouseEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode()) wrapper.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode())
.eq(StrUtil.isNotBlank(warehouseQueryRequest.getRelId()), "relId", warehouseQueryRequest.getRelId())
.eq(null != warehouseQueryRequest.getCorpOrderId(), "corpOrderId", warehouseQueryRequest.getCorpOrderId()) .eq(null != warehouseQueryRequest.getCorpOrderId(), "corpOrderId", warehouseQueryRequest.getCorpOrderId())
.eq(StrUtil.isNotBlank(warehouseQueryRequest.getOrderId()), "orderId", warehouseQueryRequest.getOrderId()) .eq(StrUtil.isNotBlank(warehouseQueryRequest.getOrderId()), "orderId", warehouseQueryRequest.getOrderId())
.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCustomerId()), "customerId", warehouseQueryRequest.getCustomerId()) .eq(StrUtil.isNotBlank(warehouseQueryRequest.getCustomerId()), "customerId", warehouseQueryRequest.getCustomerId())

@ -51,77 +51,107 @@ public class InvProductsTrService {
orderFilterRequest.setId(orderId); orderFilterRequest.setId(orderId);
List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest); List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest);
OrderEntity orderEntity = orderEntities.get(0); OrderEntity orderEntity = orderEntities.get(0);
String customerId = orderEntity.getCustomerId() + ""; String customerId = String.valueOf(orderEntity.getCustomerId());
if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) {
FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest();
filterOrderDetailRequest.setOrderId(orderId); filterOrderDetailRequest.setOrderId(orderId);
List<OrderDetailEntity> erpOrderEntities = myErpOrderService.filterOrderDetails(filterOrderDetailRequest); List<OrderDetailEntity> erpOrderEntities = myErpOrderService.filterOrderDetails(filterOrderDetailRequest);
if (erpOrderEntities != null && erpOrderEntities.size() > 0) { if (erpOrderEntities != null && erpOrderEntities.size() > 0) {
for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { for (OrderDetailEntity orderDetailEntity : erpOrderEntities) {
String nameCode = orderDetailEntity.getNameCode(); //生成或更新库存数据
UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId); InvProductEntity invProductEntity = getInvProductEntity(orderEntity, customerId, orderDetailEntity);
InvProductEntity invProductEntity = invProductService.selectByUuid(udiInfoEntity.getUuid(), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); //生成库存详情数据
if (invProductEntity == null) { genInvProductDetail(orderId, invProductEntity, customerId);
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId()));
invProductEntity.setBatchNo(orderDetailEntity.getBatchNo());
invProductEntity.setCustomerId(orderEntity.getCustomerId() + "");
invProductEntity.setExpireDate(orderDetailEntity.getExpireDate());
invProductEntity.setProductDate(orderDetailEntity.getProduceDate());
invProductEntity.setGgxh(orderDetailEntity.getGgxh());
invProductEntity.setNameCode(orderDetailEntity.getNameCode());
invProductEntity.setProductsName(orderDetailEntity.getProductName());
invProductEntity.setYlqxzcrbarmc(orderDetailEntity.getProductCompany());
invProductEntity.setZczbhhzbapzbh(orderDetailEntity.getZczbhhzbapzbh());
invProductEntity.setLocStorageCode(orderEntity.getLocStorageCode());
invProductEntity.setManufactory(udiInfoEntity.getManufactory());
if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) {
invProductEntity.setOutCount(orderDetailEntity.getCount());
invProductEntity.setInCount(0);
} else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) {
invProductEntity.setInCount(orderDetailEntity.getCount());
invProductEntity.setOutCount(0);
}
invProductService.insertInvProduct(invProductEntity);
invProductEntity = invProductService.selectByUuid(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode());
} else {
if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) {
invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount());
} else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) {
invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount());
}
invProductService.updateInvProduct(invProductEntity);
}
//查询码详情数据,用于生成库存
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setOrderId(orderId);
List<WarehouseEntity> warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest);
if (CollUtil.isNotEmpty(warehouseEntities)) {
for (WarehouseEntity warehouseEntity : warehouseEntities) {
UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId);
InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity();
invProductDetailEntity.setProductIdFk(invProductEntity.getRelIdFk() + "");
invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId()));
invProductDetailEntity.setCode(warehouseEntity.getCode());
invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId());
int actCount = inoutUtils.getActCount(tempUdi);
invProductDetailEntity.setCount(actCount * warehouseEntity.getCount());
invProductDetailEntity.setAction(warehouseEntity.getAction());
invProductDetailEntity.setBatchNo(warehouseEntity.getBatchNo());
invProductDetailEntity.setMainAction(warehouseEntity.getMainAction());
invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate());
invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate());
invProductDetailEntity.setUpdateTime(new Date());
invProductDetailEntity.setCustomerId(orderEntity.getCustomerId() + "");
invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode());
invProductDetailService.insertInvProduct(invProductDetailEntity);
}
}
} }
} }
} }
} }
/**
* /
*
* @param orderEntity
* @param customerId ID
* @param orderDetailEntity
* @return
*/
private InvProductEntity getInvProductEntity(OrderEntity orderEntity, String customerId, OrderDetailEntity orderDetailEntity) {
String nameCode = orderDetailEntity.getNameCode();
UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId);
InvProductEntity invProductEntity = invProductService.selectByRelIdFk(String.valueOf(udiInfoEntity.getId()), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode());
if (invProductEntity == null) {
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId()));
invProductEntity.setBatchNo(orderDetailEntity.getBatchNo());
invProductEntity.setCustomerId(orderEntity.getCustomerId() + "");
invProductEntity.setExpireDate(orderDetailEntity.getExpireDate());
invProductEntity.setProductDate(orderDetailEntity.getProduceDate());
invProductEntity.setGgxh(orderDetailEntity.getGgxh());
invProductEntity.setNameCode(orderDetailEntity.getNameCode());
invProductEntity.setProductsName(orderDetailEntity.getProductName());
invProductEntity.setYlqxzcrbarmc(orderDetailEntity.getProductCompany());
invProductEntity.setZczbhhzbapzbh(orderDetailEntity.getZczbhhzbapzbh());
invProductEntity.setLocStorageCode(orderEntity.getLocStorageCode());
invProductEntity.setManufactory(udiInfoEntity.getManufactory());
if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) {
invProductEntity.setOutCount(orderDetailEntity.getCount());
invProductEntity.setInCount(0);
} else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) {
invProductEntity.setInCount(orderDetailEntity.getCount());
invProductEntity.setOutCount(0);
}
//生成库存数据
invProductService.insertInvProduct(invProductEntity);
invProductEntity = invProductService.selectByRelIdFk(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode());
} else {
if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) {
invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount());
} else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) {
invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount());
}
//库存存在,更新库存数据
invProductService.updateInvProduct(invProductEntity);
}
return invProductEntity;
}
/**
*
*
* @param orderId
* @param invProductEntity
* @param customerId ID
*/
private void genInvProductDetail(String orderId, InvProductEntity invProductEntity, String customerId) {
//查询码详情数据,用于生成库存
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setOrderId(orderId);
warehouseQueryRequest.setNameCode(invProductEntity.getNameCode());
warehouseQueryRequest.setRelId(invProductEntity.getRelIdFk());
warehouseQueryRequest.setBatchNo(invProductEntity.getBatchNo());
List<WarehouseEntity> warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest);
if (CollUtil.isNotEmpty(warehouseEntities)) {
for (WarehouseEntity warehouseEntity : warehouseEntities) {
UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId);
InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity();
invProductDetailEntity.setProductIdFk(String.valueOf(invProductEntity.getRelIdFk()));
invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId()));
invProductDetailEntity.setCode(warehouseEntity.getCode());
invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId());
int actCount = inoutUtils.getActCount(tempUdi);
invProductDetailEntity.setCount(actCount * warehouseEntity.getCount());
invProductDetailEntity.setAction(warehouseEntity.getAction());
invProductDetailEntity.setBatchNo(warehouseEntity.getBatchNo());
invProductDetailEntity.setMainAction(warehouseEntity.getMainAction());
invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate());
invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate());
invProductDetailEntity.setUpdateTime(new Date());
invProductDetailEntity.setCustomerId(customerId);
invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode());
invProductDetailService.insertInvProduct(invProductDetailEntity);
}
}
}
} }

@ -63,7 +63,8 @@ public class TransInoutService {
public void transInout(OrderEntity orderEntity) { public void transInout(OrderEntity orderEntity) {
OrderFilterRequest orderFilterRequest = new OrderFilterRequest(); OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
orderFilterRequest.setCorpOrderId(orderEntity.getCorpOrderId()); orderFilterRequest.setCorpOrderId(orderEntity.getCorpOrderId());
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); //查询已完成单据 //查询已完成单据
orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS);
List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest); List<OrderEntity> orderEntities = orderService.findAll(orderFilterRequest);
OrderEntity tempEntity = new OrderEntity(); OrderEntity tempEntity = new OrderEntity();
tempEntity.setOrderId(orderEntity.getOrderId()); tempEntity.setOrderId(orderEntity.getOrderId());
@ -178,11 +179,13 @@ public class TransInoutService {
insertList.clear(); insertList.clear();
//单据处理完成后判断单据类型是否开启二次验收校验,设置验收状态 //单据处理完成后判断单据类型是否开启二次验收校验,设置验收状态
if (bussinessTypeEntity.isSecCheckEnable()) { if (bussinessTypeEntity.isSecCheckEnable()) {
tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_UN); //验收状态设置为待验收 //验收状态设置为待验收
tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_UN);
tempEntity.setRemark("待验收"); tempEntity.setRemark("待验收");
orderService.updateOrder(tempEntity); orderService.updateOrder(tempEntity);
} else { } else {
tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_NOT); //此单据类型不需要验收 //此单据类型不需要验收
tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_NOT);
tempEntity.setRemark("已完成"); tempEntity.setRemark("已完成");
orderService.updateOrder(tempEntity); orderService.updateOrder(tempEntity);
invProductsTrService.genInvProducts(orderEntity.getOrderId()); invProductsTrService.genInvProducts(orderEntity.getOrderId());

Loading…
Cancel
Save