diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/IncomingTypeEnum.java b/blade-biz-common/src/main/java/org/springblade/common/constant/IncomingTypeEnum.java index 713ca2cb2..463b5ed4c 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/IncomingTypeEnum.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/IncomingTypeEnum.java @@ -13,7 +13,8 @@ public enum IncomingTypeEnum { PACKAGE_INCOMING(6, "按件入库"), BATCH_INCOMING(7, "批量卸车入库"), UNLOAD_TRAY_INCOMING(8, "托盘卸车入库"), - UNLOAD_TRAY_ONE(9, "卸分一体"); + UNLOAD_TRAY_ONE(9, "卸分一体"), + OPEN_TO_IN(10, "开单及入库"); private Integer code; diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataOpenIncomingClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataOpenIncomingClient.java new file mode 100644 index 000000000..93869fd1f --- /dev/null +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataOpenIncomingClient.java @@ -0,0 +1,24 @@ +package com.logpm.basicdata.feign; + +import org.springblade.common.constant.ModuleNameConstant; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient( + value = ModuleNameConstant.APPLICATION_BASICDATA_NAME +) +public interface IBasicdataOpenIncomingClient { + + String API_PREFIX = "/openIncoming/client"; + + + /** + * 获取客户历史合同记录列表 + * + * @return BladePage + */ + @GetMapping(API_PREFIX+"/checkOpenIncoming") + Boolean checkOpenIncoming(@RequestParam("warehouseId") Long warehouseId, @RequestParam("brandId") Long brandId); + +} diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java index 62f8fcc1d..482860443 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java @@ -148,4 +148,7 @@ public interface IDistributionStockArticleClient { @PostMapping(API_PREFIX + "/updateByBatchId") void updateByBatchId(@RequestBody List stockArticleEntities); + + @GetMapping(API_PREFIX + "/updateAllOrderTotalNum") + void updateAllOrderTotalNum(@RequestParam String orderCode, @RequestParam Integer total); } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/InComingDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/InComingDTO.java index 9f567b977..cc5a3e2ad 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/InComingDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/InComingDTO.java @@ -26,4 +26,10 @@ public class InComingDTO implements Serializable { private List orderCodes; + + private Long userId; + private Long deptId; + private String tenantId; + private String nickName; + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataOpenIncomingClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataOpenIncomingClient.java new file mode 100644 index 000000000..984a7324a --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataOpenIncomingClient.java @@ -0,0 +1,27 @@ +package com.logpm.basicdata.feign; + +import com.logpm.basicdata.entity.BasicdataOpenIncomingSettingEntity; +import com.logpm.basicdata.service.IBasicdataOpenIncomingSettingService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Objects; + +@ApiIgnore() +@RestController +@AllArgsConstructor +public class BasicdataOpenIncomingClient implements IBasicdataOpenIncomingClient{ + + private final IBasicdataOpenIncomingSettingService basicdataOpenIncomingSettingService; + + @Override + public Boolean checkOpenIncoming(Long warehouseId, Long brandId) { + BasicdataOpenIncomingSettingEntity settingEntity = basicdataOpenIncomingSettingService.findEntityByParam(warehouseId,brandId); + if(Objects.isNull(settingEntity)){ + return false; + }else{ + return true; + } + } +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataOpenIncomingSettingMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataOpenIncomingSettingMapper.xml index 554831b43..63c248119 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataOpenIncomingSettingMapper.xml +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataOpenIncomingSettingMapper.xml @@ -21,7 +21,7 @@ where 1=1 and is_deleted = 0 and warehouse_id = #{param.warehouseId} - and brand = #{param.brand} + and brand_id = #{param.brandId} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java index 360b6203e..2f473e232 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java @@ -11,4 +11,5 @@ public interface IBasicdataOpenIncomingSettingService extends BaseService pageSignforListOwe(IPage page,@Param("param") DistributionStockArticleOweDTO stockArticleEntity); + + void updateAllOrderTotalNum(@Param("orderCode") String orderCode, @Param("total") Integer total); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml index 1ef2ad855..11f75f72c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml @@ -1319,4 +1319,10 @@ ldsa.id + + update logpm_distribution_stock_article + set total_number = #{total} + where order_code = #{orderCode} + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java index e6fd72f42..22060e12c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java @@ -254,4 +254,5 @@ public interface IDistributionStockArticleService extends BaseService pageSignforListtOwe(IPage page, Map distributionStockArticle); + void updateAllOrderTotalNum(String orderCode, Integer total); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index afa09cddf..d81d08bca 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -2014,6 +2014,11 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl advanceIds = inComingDTO.getAdvanceIds(); - try{ BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); if(Objects.isNull(myCurrentWarehouse)){ @@ -84,11 +84,12 @@ public class IncomingController { inComingDTO.setWarehouseId(myCurrentWarehouse.getId()); inComingDTO.setWarehouseName(myCurrentWarehouse.getName()); - if(advanceIds.isEmpty() || advanceIds.size() == 0){ + if(CollUtil.isEmpty(advanceIds)){ log.warn(method+"处理订单数据为空"); return R.fail(405,"处理订单数据为空"); } + return inComingService.incomingBatchOrder(inComingDTO); }catch (CustomerException e){ log.error(e.message,e); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java index 7ce18eb22..c563ccd00 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java @@ -36,4 +36,5 @@ public interface TrunklineAdvanceMapper extends BaseMapper findIncomingOrderList(@Param("param") InComingDTO inComingDTO); + Integer findAllNumByOrderCode(@Param("orderCode") String orderCode); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml index 2088d1d15..c65f3d87f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml @@ -153,4 +153,11 @@ + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java index 8aebff5a3..38f028df0 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java @@ -2,6 +2,8 @@ package com.logpm.trunkline.service; import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; +import java.util.List; + public interface IOpenOrderAsyncService { void saveLog(Long waybillId, String waybillNo, String trackType, String refer, String operationRemark, String nickName,Long userId,Long warehouseId,String warehouseName); @@ -15,4 +17,5 @@ public interface IOpenOrderAsyncService { void saveUnloadStartCarLog(TrunklineCarsLoadLineEntity currentCarsLoadLineEntity, String nickName,Long userId); + void incomingPackageBatch(List advanceIds, Long userId, Long deptId, String tenantId, String nickName,Integer incomingType); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java index 159dfd355..edba361d4 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java @@ -35,4 +35,7 @@ public interface ITrunklineAdvanceService extends BaseService findIncomingOrderList(InComingDTO inComingDTO); + + List incomingPackageBatch(Long advanceId, Long warehouseId, List detailList, Long userId, Long deptId, String tenantId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java index 94a847702..3c3f7cd2a 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java @@ -161,14 +161,35 @@ public class InComingServiceImpl implements IInComingService { @Override public R incomingBatchOrder(InComingDTO inComingDTO) { + Long warehouseId = inComingDTO.getWarehouseId(); + String warehouseName = inComingDTO.getWarehouseName(); + Integer incomingType = inComingDTO.getIncomingType(); List advanceIds = inComingDTO.getAdvanceIds(); + Long userId = inComingDTO.getUserId(); + Long deptId = inComingDTO.getDeptId(); + String tenantId = inComingDTO.getTenantId(); + String nickName = inComingDTO.getNickName(); for (Long advanceId : advanceIds) { - List list = advanceDetailService.findNoIncomingPackageCode(advanceId); - inComingDTO.setOrderPackageCode(String.join(",",list)); - incomingPackage(inComingDTO); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("advance_id",advanceId) + .eq("package_status",0); + //查询所有包件 + List detailList = advanceDetailService.list(queryWrapper); + + List orderPackageCodes = advanceService.incomingPackageBatch(advanceId, warehouseId, detailList,userId,deptId,tenantId); + + advanceDetailService.updateBatchById(detailList); + + List incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId); + advanceService.updateIncomingWarehouseName(String.join(",",incomingWarehouseNames),advanceId); + + //存入日志 + packageTrackLogAsyncService.addPackageTrackLog(tenantId,userId, deptId,nickName,orderPackageCodes,warehouseId,warehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode(),"包件"+ IncomingTypeEnum.getValue(incomingType)); + } return R.success("入库成功"); } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java index 685edf94d..5b3acbad4 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.service.impl; +import com.logpm.trunkline.dto.InComingDTO; import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; import com.logpm.trunkline.entity.TrunklineWaybillTrackEntity; @@ -34,6 +35,8 @@ public class OpenOrderAsyncServiceImpl implements IOpenOrderAsyncService { private IWarehouseWaybillClient warehouseWaybillClient; @Autowired private ITrunklineCarsLoadLineService trunklineCarsLoadLineService; + @Autowired + private IInComingService inComingService; @Async @Override @@ -219,4 +222,17 @@ public class OpenOrderAsyncServiceImpl implements IOpenOrderAsyncService { saveLog(waybillId,waybillNo,"80",nodeName+" 干线卸车",operationRemark,nickName,userId,nodeId,nodeName); } } + + @Async + @Override + public void incomingPackageBatch(List advanceIds, Long userId, Long deptId, String tenantId, String nickName,Integer incomingType) { + InComingDTO inComingDTO = new InComingDTO(); + inComingDTO.setAdvanceIds(advanceIds); + inComingDTO.setUserId(userId); + inComingDTO.setDeptId(deptId); + inComingDTO.setTenantId(tenantId); + inComingDTO.setNickName(nickName); + inComingDTO.setIncomingType(incomingType); + inComingService.incomingBatchOrder(inComingDTO); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index e064a7c7f..54da3e175 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.logpm.basic.entity.BasicMaterialEntity; import com.logpm.basic.feign.IBasicMaterialClient; @@ -33,6 +32,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.CodeNumConstant; import org.springblade.common.constant.DictBizConstant; +import org.springblade.common.constant.IncomingTypeEnum; import org.springblade.common.constant.order.*; import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; @@ -40,6 +40,7 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.cache.DictBizCache; import org.springblade.system.feign.IRegionFeign; @@ -85,6 +86,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { private final IOpenOrderAsyncService openOrderAsyncService; private final ITrunklineWaybillReturnService trunklineWaybillReturnService; + private final IBasicdataOpenIncomingClient basicdataOpenIncomingClient; @Override public IPage advancePageList(AdvanceDTO advanceDTO) { @@ -273,6 +275,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return R.success("验证成功"); } + @GlobalTransactional @Transactional(rollbackFor = ServiceException.class) @Override public R openWaybill(OpenOrderDTO openOrderDTO) { @@ -522,6 +525,12 @@ public class OpenOrderServiceImpl implements IOpenOrderService { trunklineBillladingWaybillService.updateBillladingFeeByBillladingId(billladingEntity); } + //判断是否是开单及入库的配置 + Boolean aBoolean = basicdataOpenIncomingClient.checkOpenIncoming(warehouseId, basicdataBrandEntity.getId()); + if(aBoolean){ + openOrderAsyncService.incomingPackageBatch(advanceIds,AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()),AuthUtil.getTenantId(),AuthUtil.getNickName(), IncomingTypeEnum.OPEN_TO_IN.getCode()); + } + //异步存入日志 String nickName = AuthUtil.getNickName(); Long userId = AuthUtil.getUserId(); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java index 83d6942f9..250e10208 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java @@ -36,6 +36,7 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; @@ -385,4 +386,233 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl incomingPackageBatch(Long advanceId, Long warehouseId, List detailList, Long userId, Long deptId, String tenantId) { + + Date date = new Date(); + + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if(Objects.isNull(warehouseEntity)){ + log.warn("###############incomingPackageBatch: 仓库信息不存在 warehouseId={}",warehouseId); + throw new CustomerException(405,"仓库信息不存在"); + } + String warehouseName = warehouseEntity.getName(); + + //查询暂存单数据 + TrunklineAdvanceEntity advanceEntity = baseMapper.selectById(advanceId); + if(Objects.isNull(advanceEntity)){ + log.warn("###############incomingPackageBatch: 暂存单信息不存在 advanceId={}",advanceId); + throw new CustomerException(405,"暂存单信息不存在"); + } + + String orderCode = advanceEntity.getOrderCode(); + Integer total = baseMapper.findAllNumByOrderCode(orderCode); + + Long orderId = null; + DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if(Objects.isNull(stockArticleEntity)){ + log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息"); + //订单信息为空 + String waybillNo = advanceEntity.getWaybillNo(); + + stockArticleEntity = new DistributionStockArticleEntity(); + stockArticleEntity.setCreateUser(userId); + stockArticleEntity.setUpdateUser(userId); + stockArticleEntity.setCreateDept(deptId); + stockArticleEntity.setOrderCode(orderCode); + stockArticleEntity.setServiceNumber(advanceEntity.getServiceNum()); + stockArticleEntity.setWaybillNumber(waybillNo); + stockArticleEntity.setTotalNumber(total); + stockArticleEntity.setHandQuantity(0); + stockArticleEntity.setTenantId(tenantId);// 对应租户ID + stockArticleEntity.setIsDeleted(0); + stockArticleEntity.setStatus(1); + stockArticleEntity.setWarehouse(warehouseName); + stockArticleEntity.setWarehouseId(warehouseId); + stockArticleEntity.setBrand(advanceEntity.getBrand()); + stockArticleEntity.setDescriptionGoods(advanceEntity.getPackName()); + stockArticleEntity.setWarehouseEntryTime(date); + stockArticleEntity.setGenre(1); + + String dealerName = advanceEntity.getDealerName();//暂存单经销商名称 + stockArticleEntity.setDealerCode(advanceEntity.getDealerCode()); + stockArticleEntity.setDealerName(advanceEntity.getDealerName()); + + stockArticleEntity.setTypeService("1");//默认商配 + + if(!StringUtil.isBlank(waybillNo)){ + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if(!Objects.isNull(waybillEntity)){ + Long consigneeId = waybillEntity.getConsigneeId(); + + BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); + if(!Objects.isNull(clientEntity)){ + stockArticleEntity.setMallId(clientEntity.getId()); + stockArticleEntity.setMallName(clientEntity.getClientName()); + stockArticleEntity.setMallCode(clientEntity.getClientCode()); + } + String consignee = waybillEntity.getConsignee(); + String consigneeName = waybillEntity.getConsigneeName(); + String consigneeMobile = waybillEntity.getConsigneeMobile(); + String consigneeAddress = waybillEntity.getConsigneeAddress(); + stockArticleEntity.setConsigneeUnit(consignee); + stockArticleEntity.setConsigneePerson(consigneeName); + stockArticleEntity.setConsigneeMobile(consigneeMobile); + stockArticleEntity.setConsigneeAddress(consigneeAddress); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + }else{ + Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); + BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); + if(!Objects.isNull(basicdataClientEntity)){ + String clientType = basicdataClientEntity.getClientType(); + if("5".equals(clientType)){ + stockArticleEntity.setStoreId(basicdataClientEntity.getId()); + stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); + stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); + //查询门店的父级商场 + Long pid = basicdataClientEntity.getPid(); + BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); + if(!Objects.isNull(pidEntity)){ + String pidEntityClientType = pidEntity.getClientType(); + if("2".equals(pidEntityClientType)){ + //商城 + stockArticleEntity.setMallId(pidEntity.getId()); + stockArticleEntity.setMallName(pidEntity.getClientName()); + stockArticleEntity.setMallCode(pidEntity.getClientCode()); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + } + }else if("2".equals(clientType)){ + //商城 + stockArticleEntity.setMallId(basicdataClientEntity.getId()); + stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); + stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + } + } + + stockArticleEntity.setCustomerName(advanceEntity.getCustomerName()); + stockArticleEntity.setCustomerTelephone(advanceEntity.getCustomerPhone()); + stockArticleEntity.setCustomerAddress(advanceEntity.getCustomerAddress()); + stockArticleEntity.setStockupStatus("10"); + stockArticleEntity.setReservationStatus("10"); + stockArticleEntity.setOrderStatus("0"); + stockArticleEntity.setGroundingStatus("10"); + stockArticleEntity.setOrderReceiveStatus("10"); + stockArticleEntity.setFreezeStatus("10"); + stockArticleEntity.setNotification(2); + stockArticleEntity.setIsHaveData(2); + stockArticleEntity.setTrainNumber(advanceEntity.getTrainNumber()); + stockArticleEntity.setSortingQuantity(0); + stockArticleEntity.setDeliveryQuantity(0); + stockArticleEntity.setTransferQuantity(0); + stockArticleEntity.setSigninQuantity(0); + orderId = stockArticleClient.addData(stockArticleEntity); + }else{ + stockArticleEntity.setTotalNumber(total); + stockArticleClient.saveOrUpdate(stockArticleEntity); + orderId = stockArticleEntity.getId(); + } + if(Objects.isNull(orderId)){ + log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}",orderId); + throw new CustomerException(405,"订单信息有误"); + } + + stockArticleClient.updateAllOrderTotalNum(orderCode,total); + + List parcelListEntityList = new ArrayList<>(); + List orderPackageCodes = new ArrayList<>(); + for (TrunklineAdvanceDetailEntity advanceDetailEntity : detailList) { + String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); + DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); + parcelList.setCreateUser(userId); + parcelList.setUpdateUser(userId); + parcelList.setCreateDept(deptId); + parcelList.setTenantId(tenantId); + parcelList.setIsDeleted(0); + parcelList.setStatus(1); + parcelList.setWarehouse(warehouseEntity.getName()); + parcelList.setWarehouseId(warehouseId); + String waybillNo = advanceEntity.getWaybillNo(); + if(StringUtil.isNotBlank(waybillNo)){ + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if(!Objects.isNull(waybillEntity)){ + parcelList.setWaybillId(waybillEntity.getId()+""); + parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); + parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); + parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName()); + parcelList.setAcceptWarehouseId(waybillEntity.getDestinationWarehouseId()); + parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); + } + } + parcelList.setConditions(1); + parcelList.setOrderPackageCode(orderPackageCode); + parcelList.setFirsts(advanceDetailEntity.getFirstPackName()); + parcelList.setSecond(advanceDetailEntity.getSecondPackName()); + parcelList.setThirdProduct(advanceDetailEntity.getThirdPackName()); + parcelList.setQuantity(1); + parcelList.setStockArticleId(orderId); + parcelList.setOrderCode(orderCode); + parcelList.setServiceNumber(advanceDetailEntity.getServiceNum()); + parcelList.setIsTransfer(1); + parcelList.setAdvanceId(advanceId); + + Long materialId = advanceDetailEntity.getMaterialId(); + String materialCode = advanceDetailEntity.getMaterialCode(); + String materialName = advanceDetailEntity.getMaterialName(); + if(Objects.isNull(materialId)){ + BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); + if(!Objects.isNull(materialEntity)){ + parcelList.setMaterialId(materialEntity.getId()); + parcelList.setMaterialName(materialEntity.getName()); + parcelList.setMaterialCode(materialEntity.getProductCode()); + parcelList.setMaterialUnit(materialEntity.getSpecification()); + } + }else{ + BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); + if(!Objects.isNull(materialOwnId)){ + parcelList.setMaterialId(materialOwnId.getId()); + parcelList.setMaterialName(materialOwnId.getName()); + parcelList.setMaterialCode(materialOwnId.getProductCode()); + parcelList.setMaterialUnit(materialOwnId.getSpecification()); + } + + } + parcelList.setBrandName(advanceDetailEntity.getBrand()); + parcelList.setOrderPackageStatus("20"); + parcelList.setOrderPackageFreezeStatus("10"); + parcelList.setOrderPackageGroundingStatus("10"); + parcelList.setOrderPackageStockupStatus("10"); + parcelList.setOrderPackageReservationStatus("10"); + parcelList.setOrderPackageLoadingStatus("10"); + parcelList.setWarehouseEntryTimeEnd(date); + parcelList.setDealerCode(stockArticleEntity.getDealerCode()); + parcelList.setDealerName(stockArticleEntity.getDealerName()); + parcelListEntityList.add(parcelList); + + advanceDetailEntity.setPackageStatus("1"); + advanceDetailEntity.setWaybillNo(waybillNo); + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + orderPackageCodes.add(orderPackageCode); + } + parcelListClient.addBatch(parcelListEntityList); + + return orderPackageCodes; + } + }