|
|
|
@ -17,8 +17,10 @@ import com.logpm.business.service.IBusinessAsyncService;
|
|
|
|
|
import com.logpm.business.service.IBusinessPreOrderService; |
|
|
|
|
import com.logpm.business.vo.*; |
|
|
|
|
import com.logpm.distribution.entity.DistributionParcelListEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockArticleEntity; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionDeliveryListClient; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionParcelListClient; |
|
|
|
|
import com.logpm.distribution.feign.IDistributionStockArticleClient; |
|
|
|
|
import com.logpm.trunkline.dto.InComingDTO; |
|
|
|
|
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; |
|
|
|
|
import com.logpm.trunkline.feign.IInComingClient; |
|
|
|
@ -56,6 +58,8 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl<BusinessPreOrde
|
|
|
|
|
private final BladeRedis bladeRedis; |
|
|
|
|
private final IWarehouseTrayTypeClient warehouseTrayTypeClient; |
|
|
|
|
private final IDistributionDeliveryListClient distributionDeliveryListClient; |
|
|
|
|
private final IDistributionStockArticleClient distributionStockArticleClient; |
|
|
|
|
private final IDistributionParcelListClient distributionParcelListClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -201,40 +205,148 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl<BusinessPreOrde
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
|
|
|
|
businessSanDTO.setWarehouseId(myCurrentWarehouse.getId()); |
|
|
|
|
businessSanDTO.setWarehouseName(myCurrentWarehouse.getName()); |
|
|
|
|
String orderPackageCode = businessSanDTO.getOrderPackageCode(); |
|
|
|
|
String distrCarNumber = businessSanDTO.getDistrCarNumber(); |
|
|
|
|
if ("1".equals(businessSanDTO.getConditions())) { |
|
|
|
|
businessSanDTO.setWarehouseId(myCurrentWarehouse.getId()); |
|
|
|
|
businessSanDTO.setWarehouseName(myCurrentWarehouse.getName()); |
|
|
|
|
String orderPackageCode = businessSanDTO.getOrderPackageCode(); |
|
|
|
|
String distrCarNumber = businessSanDTO.getDistrCarNumber(); |
|
|
|
|
|
|
|
|
|
if (Func.isAllEmpty(orderPackageCode, distrCarNumber, businessSanDTO.getInWarehouseException())) { |
|
|
|
|
return Resp.scanFail("扫描失败", "没有包件或者车次"); |
|
|
|
|
} |
|
|
|
|
// 查询配送车次下面所有的包件
|
|
|
|
|
LambdaQueryWrapper<BusinessPreOrderEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(BusinessPreOrderEntity::getDistrCarNumber, distrCarNumber); |
|
|
|
|
queryWrapper.eq(BusinessPreOrderEntity::getIsDeleted, 0); |
|
|
|
|
List<BusinessPreOrderEntity> list = baseMapper.selectList(queryWrapper); |
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
return Resp.scanFail("扫描失败", "车次信息不存在"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Func.isAllEmpty(orderPackageCode, distrCarNumber, businessSanDTO.getInWarehouseException())) { |
|
|
|
|
return Resp.scanFail("扫描失败", "没有包件或者车次"); |
|
|
|
|
} |
|
|
|
|
// 查询配送车次下面所有的包件
|
|
|
|
|
LambdaQueryWrapper<BusinessPreOrderEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(BusinessPreOrderEntity::getDistrCarNumber, distrCarNumber); |
|
|
|
|
queryWrapper.eq(BusinessPreOrderEntity::getIsDeleted, 0); |
|
|
|
|
List<BusinessPreOrderEntity> list = baseMapper.selectList(queryWrapper); |
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
return Resp.scanFail("扫描失败", "车次信息不存在"); |
|
|
|
|
} |
|
|
|
|
// 异常入库
|
|
|
|
|
if (1 == businessSanDTO.getInWarehouseException()) { |
|
|
|
|
Resp a = handleExceptionalWarehourse(businessSanDTO, list, orderPackageCode, distrCarNumber); |
|
|
|
|
if (a != null) return a; |
|
|
|
|
} else { |
|
|
|
|
//正常入口
|
|
|
|
|
Resp scanFail = handleNormalWarehourse(businessSanDTO, orderPackageCode, list, distrCarNumber); |
|
|
|
|
if (scanFail != null) return scanFail; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else if ("3".equals(businessSanDTO.getConditions())) { |
|
|
|
|
// 零担
|
|
|
|
|
LambdaQueryWrapper<BusinessPreOrderEntity> queryWrapper3 = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper3.eq(BusinessPreOrderEntity::getDistrCarNumber, businessSanDTO.getDistrCarNumber()); |
|
|
|
|
queryWrapper3.eq(BusinessPreOrderEntity::getReservationCode, businessSanDTO.getReservationCode()); |
|
|
|
|
queryWrapper3.eq(BusinessPreOrderEntity::getOrderCode, businessSanDTO.getOrderCode()); |
|
|
|
|
queryWrapper3.eq(BusinessPreOrderEntity::getFirsts, businessSanDTO.getFirsts()); |
|
|
|
|
List<BusinessPreOrderEntity> list3 = baseMapper.selectList(queryWrapper3); |
|
|
|
|
if (list3.isEmpty()) { |
|
|
|
|
throw new CustomerException("入库数据错误,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
BusinessPreOrderEntity businessPreOrderEntity = list3.get(0); |
|
|
|
|
if (1 == businessPreOrderEntity.getInWarehouse()) { |
|
|
|
|
return Resp.scanFail("操作失败", businessSanDTO.getFirsts() + "已入库"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 构建 订单
|
|
|
|
|
DistributionStockArticleEntity distributionStockArticleEntity = checkStockArticle(businessPreOrderEntity, myCurrentWarehouse); |
|
|
|
|
// 构建 订单下级【包件】
|
|
|
|
|
DistributionParcelListEntity distributionParcelListEntityByOrderCodeAndFirstName = distributionParcelListClient.findDistributionParcelListEntityByOrderCodeAndFirstName(businessPreOrderEntity.getOrderCode(), businessSanDTO.getFirsts(), myCurrentWarehouse.getId()); |
|
|
|
|
|
|
|
|
|
int temp = 0; |
|
|
|
|
if (distributionParcelListEntityByOrderCodeAndFirstName == null) { |
|
|
|
|
// 执行新增功能
|
|
|
|
|
DistributionParcelListEntity distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId = distributionParcelListClient.findDistributionParcelListEntityByOrderCodeAndFirstNameAndTenantId(businessPreOrderEntity.getFromTenantId(), businessPreOrderEntity.getOrderCode(), businessSanDTO.getFirsts(), businessPreOrderEntity.getWarehouseId()); |
|
|
|
|
if (distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId != null) { |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setId(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setTenantId(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setCreateUser(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setUpdateUser(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setCreateTime(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setUpdateTime(null); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setOrderPackageReservationStatus("10"); |
|
|
|
|
// 卸车数量作为入库数量
|
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setQuantity(businessSanDTO.getUnloadNum()); |
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId.setStockArticleId(distributionStockArticleEntity.getId()); |
|
|
|
|
distributionParcelListClient.add(distributionParcelListEntityByOrderCodeAndFirstNameAndTenantId); |
|
|
|
|
temp = businessSanDTO.getUnloadNum(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
// 修改其入库数量
|
|
|
|
|
if(distributionParcelListEntityByOrderCodeAndFirstName.getQuantity()<businessSanDTO.getUnloadNum()){ |
|
|
|
|
temp = distributionParcelListEntityByOrderCodeAndFirstName.getQuantity() - businessSanDTO.getUnloadNum(); |
|
|
|
|
}else{ |
|
|
|
|
temp = businessSanDTO.getUnloadNum() - distributionParcelListEntityByOrderCodeAndFirstName.getQuantity(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
distributionParcelListEntityByOrderCodeAndFirstName.setQuantity(businessSanDTO.getUnloadNum()); |
|
|
|
|
distributionParcelListClient.update(distributionParcelListEntityByOrderCodeAndFirstName); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
distributionStockArticleEntity.setHandQuantity(distributionStockArticleEntity.getHandQuantity() + temp); |
|
|
|
|
distributionStockArticleEntity.setIncomingNum(distributionStockArticleEntity.getIncomingNum() + temp); |
|
|
|
|
distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity); |
|
|
|
|
|
|
|
|
|
// 修改预入库数据
|
|
|
|
|
businessPreOrderEntity.setInWarehouse(1); |
|
|
|
|
businessPreOrderEntity.setUnloadNum(businessSanDTO.getUnloadNum()); |
|
|
|
|
this.updateById(businessPreOrderEntity); |
|
|
|
|
return Resp.scanSuccess("操作成功", "入库"+businessSanDTO.getUnloadNum()+"件"); |
|
|
|
|
|
|
|
|
|
// 异常入库
|
|
|
|
|
if (1 == businessSanDTO.getInWarehouseException()) { |
|
|
|
|
Resp a = handleExceptionalWarehourse(businessSanDTO, list, orderPackageCode, distrCarNumber); |
|
|
|
|
if (a != null) return a; |
|
|
|
|
} else { |
|
|
|
|
//正常入口
|
|
|
|
|
Resp scanFail = handleNormalWarehourse(businessSanDTO, orderPackageCode, list, distrCarNumber); |
|
|
|
|
if (scanFail != null) return scanFail; |
|
|
|
|
|
|
|
|
|
log.warn("?? 参数传递错误 "); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("系统异常", e); |
|
|
|
|
throw new CustomerException(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Resp.scanFail("扫描失败", "系统错误"); |
|
|
|
|
return Resp.scanFail("操作失败", "系统错误"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 对订单进行处理 当订单不存在的时候进行新增 |
|
|
|
|
* |
|
|
|
|
* @param businessPreOrderEntity |
|
|
|
|
* @param myCurrentWarehouse |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private DistributionStockArticleEntity checkStockArticle(BusinessPreOrderEntity businessPreOrderEntity, BasicdataWarehouseEntity myCurrentWarehouse) { |
|
|
|
|
DistributionStockArticleEntity byOrderSelfNumAndTenantId = distributionStockArticleClient.findByOrderSelfNum(businessPreOrderEntity.getOrderCode(), myCurrentWarehouse.getId()); |
|
|
|
|
if (byOrderSelfNumAndTenantId == null) { |
|
|
|
|
// 执行新增功能
|
|
|
|
|
byOrderSelfNumAndTenantId = distributionStockArticleClient.findByOrderSelfNumAndTenantId(businessPreOrderEntity.getFromTenantId(), businessPreOrderEntity.getOrderCode(), businessPreOrderEntity.getWarehouseId()); |
|
|
|
|
if (byOrderSelfNumAndTenantId != null) { |
|
|
|
|
byOrderSelfNumAndTenantId.setId(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setTenantId(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setCreateUser(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setUpdateUser(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setCreateTime(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setUpdateTime(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setOrderStatus("20"); |
|
|
|
|
byOrderSelfNumAndTenantId.setReservationStatus("10"); |
|
|
|
|
byOrderSelfNumAndTenantId.setWarehouse(myCurrentWarehouse.getName()); |
|
|
|
|
byOrderSelfNumAndTenantId.setWarehouseId(myCurrentWarehouse.getId()); |
|
|
|
|
byOrderSelfNumAndTenantId.setDeliveryQuantity(0); |
|
|
|
|
byOrderSelfNumAndTenantId.setStoreTime(null); |
|
|
|
|
byOrderSelfNumAndTenantId.setWaybillId(null); |
|
|
|
|
// 对应新增的订单默认在库件数未0
|
|
|
|
|
byOrderSelfNumAndTenantId.setHandQuantity(0); |
|
|
|
|
Long id = distributionStockArticleClient.addData(byOrderSelfNumAndTenantId); |
|
|
|
|
byOrderSelfNumAndTenantId.setId(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return byOrderSelfNumAndTenantId; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -503,7 +615,7 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl<BusinessPreOrde
|
|
|
|
|
int loadNum = entities.stream().mapToInt(BusinessPreOrderEntity::getLoadNum).sum(); |
|
|
|
|
|
|
|
|
|
// 卸车数量== 入库数量
|
|
|
|
|
int inNum =entities.stream().mapToInt(BusinessPreOrderEntity::getUnloadNum).sum(); |
|
|
|
|
int inNum = entities.stream().mapToInt(BusinessPreOrderEntity::getUnloadNum).sum(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 零担无法进行异常卸车 |
|
|
|
|