Browse Source

1.配置开单及入库 功能完成

2.增加暂存单入库更新全库订单数量
3.修复事务问题
4.优化批量入库的逻辑
pull/31/head
zhenghaoyu 12 months ago
parent
commit
31619ae114
  1. 3
      blade-biz-common/src/main/java/org/springblade/common/constant/IncomingTypeEnum.java
  2. 24
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataOpenIncomingClient.java
  3. 3
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java
  4. 6
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/InComingDTO.java
  5. 27
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataOpenIncomingClient.java
  6. 2
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataOpenIncomingSettingMapper.xml
  7. 1
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java
  8. 11
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataOpenIncomingSettingServiceImpl.java
  9. 5
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java
  10. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java
  11. 6
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
  12. 1
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java
  13. 5
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java
  14. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/IncomingController.java
  15. 1
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java
  16. 7
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml
  17. 3
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java
  18. 3
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java
  19. 27
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java
  20. 16
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java
  21. 11
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java
  22. 230
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java

3
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;

24
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);
}

3
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<DistributionStockArticleEntity> stockArticleEntities);
@GetMapping(API_PREFIX + "/updateAllOrderTotalNum")
void updateAllOrderTotalNum(@RequestParam String orderCode, @RequestParam Integer total);
}

6
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<String> orderCodes;
private Long userId;
private Long deptId;
private String tenantId;
private String nickName;
}

27
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;
}
}
}

2
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}
</select>

1
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataOpenIncomingSettingService.java

@ -11,4 +11,5 @@ public interface IBasicdataOpenIncomingSettingService extends BaseService<Basicd
R addEntity(BasicdataOpenIncomingDTO basicdataOpenIncomingDTO);
BasicdataOpenIncomingSettingEntity findEntityByParam(Long warehouseId, Long brandId);
}

11
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataOpenIncomingSettingServiceImpl.java

@ -6,10 +6,8 @@ import com.logpm.basicdata.dto.BasicdataOpenIncomingDTO;
import com.logpm.basicdata.entity.BasicdataOpenIncomingSettingEntity;
import com.logpm.basicdata.mapper.BasicdataOpenIncomingSettingMapper;
import com.logpm.basicdata.service.IBasicdataOpenIncomingSettingService;
import com.logpm.basicdata.vo.BasicdataOpenIncomingSettingVO;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
@ -44,4 +42,13 @@ public class BasicdataOpenIncomingSettingServiceImpl extends BaseServiceImpl<Bas
return R.success("新增成功");
}
@Override
public BasicdataOpenIncomingSettingEntity findEntityByParam(Long warehouseId, Long brandId) {
BasicdataOpenIncomingDTO basicdataOpenIncomingDTO = new BasicdataOpenIncomingDTO();
basicdataOpenIncomingDTO.setWarehouseId(warehouseId);
basicdataOpenIncomingDTO.setBrandId(brandId);
return baseMapper.findEntityByParam(basicdataOpenIncomingDTO);
}
}

5
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java

@ -306,4 +306,9 @@ public class DistributionStockArticleClient implements IDistributionStockArticle
distributionStockArticleService.updateBatchById(stockArticleEntities);
}
@Override
public void updateAllOrderTotalNum(String orderCode, Integer total) {
distributionStockArticleService.updateAllOrderTotalNum(orderCode,total);
}
}

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java

@ -191,4 +191,6 @@ public interface DistributionStockArticleMapper extends BaseMapper<DistributionS
* @return
*/
IPage<DistributionSignforStockArticleVO> pageSignforListOwe(IPage<DistributionSignforStockArticleVO> page,@Param("param") DistributionStockArticleOweDTO stockArticleEntity);
void updateAllOrderTotalNum(@Param("orderCode") String orderCode, @Param("total") Integer total);
}

6
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml

@ -1319,4 +1319,10 @@
ldsa.id
</select>
<update id="updateAllOrderTotalNum">
update logpm_distribution_stock_article
set total_number = #{total}
where order_code = #{orderCode}
</update>
</mapper>

1
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java

@ -254,4 +254,5 @@ public interface IDistributionStockArticleService extends BaseService<Distributi
IPage<DistributionSignforStockArticleVO> pageSignforListtOwe(IPage<DistributionSignforStockArticleVO> page, Map<String, Object> distributionStockArticle);
void updateAllOrderTotalNum(String orderCode, Integer total);
}

5
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java

@ -2014,6 +2014,11 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl<Distrib
return distributionStockArticleEntityIPage;
}
@Override
public void updateAllOrderTotalNum(String orderCode, Integer total) {
baseMapper.updateAllOrderTotalNum(orderCode,total);
}
@Override
public R findEditCustomerLog(Long orderId) {

5
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/IncomingController.java

@ -1,5 +1,6 @@
package com.logpm.trunkline.controller;
import cn.hutool.core.collection.CollUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
@ -74,7 +75,6 @@ public class IncomingController {
log.info(method+"请求参数{}",inComingDTO);
List<Long> 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);

1
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java

@ -36,4 +36,5 @@ public interface TrunklineAdvanceMapper extends BaseMapper<TrunklineAdvanceEntit
List<TrunklineAdvanceVO> findIncomingOrderList(@Param("param") InComingDTO inComingDTO);
Integer findAllNumByOrderCode(@Param("orderCode") String orderCode);
}

7
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml

@ -153,4 +153,11 @@
</if>
</select>
<select id="findAllNumByOrderCode" resultType="int">
select sum(total_num)
from logpm_trunkline_advance
where order_code = #{orderCode}
and is_deleted = 0
</select>
</mapper>

3
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<Long> advanceIds, Long userId, Long deptId, String tenantId, String nickName,Integer incomingType);
}

3
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java

@ -35,4 +35,7 @@ public interface ITrunklineAdvanceService extends BaseService<TrunklineAdvanceEn
void updateIncomingWarehouseName(String incomingWarehouseName, Long advanceId);
List<TrunklineAdvanceVO> findIncomingOrderList(InComingDTO inComingDTO);
List<String> incomingPackageBatch(Long advanceId, Long warehouseId, List<TrunklineAdvanceDetailEntity> detailList, Long userId, Long deptId, String tenantId);
}

27
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<Long> advanceIds = inComingDTO.getAdvanceIds();
Long userId = inComingDTO.getUserId();
Long deptId = inComingDTO.getDeptId();
String tenantId = inComingDTO.getTenantId();
String nickName = inComingDTO.getNickName();
for (Long advanceId : advanceIds) {
List<String> list = advanceDetailService.findNoIncomingPackageCode(advanceId);
inComingDTO.setOrderPackageCode(String.join(",",list));
incomingPackage(inComingDTO);
QueryWrapper<TrunklineAdvanceDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("advance_id",advanceId)
.eq("package_status",0);
//查询所有包件
List<TrunklineAdvanceDetailEntity> detailList = advanceDetailService.list(queryWrapper);
List<String> orderPackageCodes = advanceService.incomingPackageBatch(advanceId, warehouseId, detailList,userId,deptId,tenantId);
advanceDetailService.updateBatchById(detailList);
List<String> 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("入库成功");
}
}

16
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<Long> 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);
}
}

11
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<TrunklineAdvanceVO> 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();

230
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<TrunklineAdvanc
return baseMapper.findIncomingOrderList(inComingDTO);
}
@Override
public List<String> incomingPackageBatch(Long advanceId, Long warehouseId, List<TrunklineAdvanceDetailEntity> 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<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>();
List<String> 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;
}
}

Loading…
Cancel
Save