Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dist.1.3.0
zhaoqiaobo 10 months ago
parent
commit
733c3612aa
  1. 3
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java
  2. 8
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java
  3. 9
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java
  4. 17
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java
  5. 8
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/IncomingController.java
  6. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingPackageMapper.java
  7. 9
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingPackageMapper.xml
  8. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java
  9. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java
  10. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineBillladingPackageServicie.java
  11. 284
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java
  12. 549
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java
  13. 287
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingPackageServiceImpl.java

3
blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java

@ -189,4 +189,7 @@ public interface IDistributionParcelListClient {
@PostMapping(API_PREFIX + "/saveorUpdateBatchByOP")
void saveorUpdateBatchByOP(@RequestBody List<DistributionParcelListEntity> parcelListEntityList);
@PostMapping(API_PREFIX + "/findListByOrderCodesAndWarehouseId")
List<DistributionParcelListEntity> findListByOrderCodesAndWarehouseId(@RequestParam Set<String> orderCodeSet, @RequestParam Long warehouseId);
}

8
blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java

@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 配送在库订单 Feign接口类
@ -175,4 +176,11 @@ public interface IDistributionStockArticleClient {
*/
@PostMapping(value = API_PREFIX + "/updateCustomerAllByOrderCode",consumes = MediaType.APPLICATION_JSON_VALUE)
void updateCustomerAllByOrderCode(@RequestBody String data);
@PostMapping(value = API_PREFIX + "/findListByOrderCodesAndWarehouseId",consumes = MediaType.APPLICATION_JSON_VALUE)
List<DistributionStockArticleEntity> findListByOrderCodesAndWarehouseId(@RequestParam Set<String> orderCodeSet, @RequestParam Long warehouseId);
@PostMapping(value = API_PREFIX + "/addReturnList",consumes = MediaType.APPLICATION_JSON_VALUE)
List<DistributionStockArticleEntity> addReturnList(@RequestBody List<DistributionStockArticleEntity> addStockArticleEntities);
}

9
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java

@ -421,4 +421,13 @@ public class DistributionParcelListClient implements IDistributionParcelListClie
distributionParcelListService.updateBatchById(parcelListEntityList);
log.info("欧派系统数据修改包件信息:{}", JSONUtil.toJsonStr(parcelListEntityList));
}
@Override
public List<DistributionParcelListEntity> findListByOrderCodesAndWarehouseId(Set<String> orderCodeSet, Long warehouseId) {
QueryWrapper<DistributionParcelListEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.in("order_code", orderCodeSet)
.eq("warehouse_id", warehouseId);
return distributionParcelListService.list(queryWrapper);
}
}

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

@ -35,13 +35,13 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* 配送在库订单 Feign实现类
@ -335,4 +335,19 @@ public class DistributionStockArticleClient implements IDistributionStockArticle
distributionStockArticleService.updateCustomerAllByOrderCode(data);
}
@Override
public List<DistributionStockArticleEntity> findListByOrderCodesAndWarehouseId(Set<String> orderCodeSet, Long warehouseId) {
QueryWrapper<DistributionStockArticleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.in("order_code",orderCodeSet)
.eq("warehouse_id",warehouseId);
return distributionStockArticleService.list(queryWrapper);
}
@Override
public List<DistributionStockArticleEntity> addReturnList(List<DistributionStockArticleEntity> addStockArticleEntities) {
distributionStockArticleService.saveBatch(addStockArticleEntities);
return addStockArticleEntities;
}
}

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

@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -56,6 +57,13 @@ public class IncomingController {
log.warn(method+"入库方式不正确 incomingType={}",incomingType);
return R.fail(405,"入库方式不正确");
}
String orderPackageCode = inComingDTO.getOrderPackageCode();
if(StringUtil.isBlank(orderPackageCode)){
log.warn(method+"包件码不能为空 orderPackageCode={}",orderPackageCode);
return R.fail(405,"包件码不能为空");
}
return inComingService.findIncomingOrderList(inComingDTO);
}catch (CustomerException e){
log.error(e.message,e);

4
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingPackageMapper.java

@ -8,10 +8,14 @@ import com.logpm.trunkline.vo.TrunklineBillladingPackageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface TrunklineBillladingPackageMapper extends BaseMapper<TrunklineBillladingPackageEntity> {
IPage<TrunklineBillladingPackageVO> findBillladingPackageDetail(IPage<Object> page, @Param("param") BillladingDTO billladingDTO);
TrunklineBillladingPackageEntity findBillladingPackage(@Param("packageCode") String packageCode);
List<String> findBillladingPackages(@Param("orderPackageCodes") List<String> orderPackageCodes);
}

9
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineBillladingPackageMapper.xml

@ -64,4 +64,13 @@
</select>
<select id="findBillladingPackages" resultType="String">
select order_package_code
from logpm_trunkline_billlading_package
where order_package_code in
<foreach collection="orderPackageCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java

@ -8,6 +8,8 @@ public interface IInComingService {
R incomingPackage(InComingDTO inComingDTO);
R incomingPackages(InComingDTO inComingDTO);
R findIncomingOrderList(InComingDTO inComingDTO);
R incomingBatchOrder(InComingDTO inComingDTO, WarehouseWaybillEntity waybillEntity);

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

@ -40,4 +40,6 @@ public interface ITrunklineAdvanceService extends BaseService<TrunklineAdvanceEn
List<String> incomingPackageBatch(Long advanceId, Long warehouseId, List<TrunklineAdvanceDetailEntity> detailList, Long userId, Long deptId, String tenantId, WarehouseWaybillEntity waybillEntity);
List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(List<String> orderCodeSet);
boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId);
}

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

@ -6,6 +6,8 @@ import com.logpm.trunkline.entity.TrunklineBillladingPackageEntity;
import com.logpm.trunkline.vo.TrunklineBillladingPackageVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface ITrunklineBillladingPackageServicie extends BaseService<TrunklineBillladingPackageEntity> {
void saveEntity(String orderPackageCode, Long billladingId,Long warehouseId,Integer incomingType);
@ -14,4 +16,7 @@ public interface ITrunklineBillladingPackageServicie extends BaseService<Trunkli
TrunklineBillladingPackageEntity findBillladingPackage(String packageCode);
List<String> findBillladingPackages(List<String> orderPackageCodes);
void saveEntityBatch(List<String> noOrderPackageCodes, Long billladingId, Long warehouseId, Integer incomingType);
}

284
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java

@ -15,11 +15,7 @@ import com.logpm.trunkline.dto.InComingDTO;
import com.logpm.trunkline.dto.OrderStatusDTO;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineBillladingPackageEntity;
import com.logpm.trunkline.service.IInComingService;
import com.logpm.trunkline.service.IPackageTrackLogAsyncService;
import com.logpm.trunkline.service.ITrunklineAdvanceDetailService;
import com.logpm.trunkline.service.ITrunklineAdvanceService;
import com.logpm.trunkline.service.ITrunklineBillladingPackageServicie;
import com.logpm.trunkline.service.*;
import com.logpm.trunkline.vo.TrunklineAdvanceVO;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient;
@ -28,20 +24,17 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.IncomingTypeEnum;
import org.springblade.common.constant.RabbitConstant;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -60,7 +53,7 @@ public class InComingServiceImpl implements IInComingService {
@Override
public R incomingPackage(InComingDTO inComingDTO) {
public R incomingPackages(InComingDTO inComingDTO) {
String orderPackageCode = inComingDTO.getOrderPackageCode();//包件码
Long warehouseId = inComingDTO.getWarehouseId();//仓库id
String warehouseName = inComingDTO.getWarehouseName();
@ -179,6 +172,271 @@ public class InComingServiceImpl implements IInComingService {
return R.success("入库成功");
}
@Transactional(rollbackFor = Exception.class)
public R incomingPackage(InComingDTO inComingDTO) {
String orderPackageCode = inComingDTO.getOrderPackageCode();//包件码
Long warehouseId = inComingDTO.getWarehouseId();//仓库id
String warehouseName = inComingDTO.getWarehouseName();
if (StringUtil.isBlank(warehouseName)) {
BasicdataWarehouseEntity warehouseEntity = warehouseClient.getEntityWarehouseId(warehouseId);
if (!Objects.isNull(warehouseEntity)) {
warehouseName = warehouseEntity.getName();
}
}
Long billladingId = inComingDTO.getBillladingId();//提货单id
Integer incomingType = inComingDTO.getIncomingType();//入库类型 1码板打托 2扫码入库 3直接入库 4 按车次号入库 5按订单入库 6扫描入库 7 批量卸车入库 8卸车托盘 9卸分一体 10补录数据入库
String trayCode = inComingDTO.getTrayCode();//托盘码
String trayType = inComingDTO.getTrayType();//打托方式
List<String> packageCodes = Arrays.asList(orderPackageCode.split(","));
log.info("############incomingPackage: 包件入库开始 packageCodes={} billladingId={} warehouseId={}", packageCodes, billladingId, warehouseId);
//包件入库开始
//查询包件是否有数据
QueryWrapper<TrunklineAdvanceDetailEntity> advanceDetailQueryWrapper = new QueryWrapper<>();
advanceDetailQueryWrapper.in("order_package_code", packageCodes);
List<TrunklineAdvanceDetailEntity> advanceDetailEntityList = advanceDetailService.list(advanceDetailQueryWrapper);
if (advanceDetailEntityList.isEmpty()) {
log.warn("############incomingPackage: 包件不存在 packageCodes={} warehouseId={}", packageCodes, warehouseId);
return Resp.scanFail(405, "包件无数据", "包件无数据");
}
//把advanceDetailEntityList通过packageStatus分组
Map<String, List<TrunklineAdvanceDetailEntity>> advanceDetailEntityMap = advanceDetailEntityList.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getPackageStatus));
String finalWarehouseName = warehouseName;
advanceDetailEntityMap.keySet().forEach(packageStatus -> {
List<TrunklineAdvanceDetailEntity> advanceDetailEntities = advanceDetailEntityMap.get(packageStatus);
if(!advanceDetailEntities.isEmpty()){
//提取advanceDetailEntities中所有元素的orderPackageCode组成一个List<String>
List<String> orderPackageCodes = advanceDetailEntities.stream()
.map(TrunklineAdvanceDetailEntity::getOrderPackageCode)
.collect(Collectors.toList());
if("0".equals(packageStatus)){
//未入库包件
Set<Long> advanceIds = new HashSet<>();
//1.修改暂存单包件入库状态
advanceDetailEntities.forEach(advanceDetailEntity -> {
advanceIds.add(advanceDetailEntity.getId());
advanceDetailEntity.setPackageStatus("1");
advanceDetailEntity.setIncomingTime(new Date());
advanceDetailEntity.setIncomingWarehouseId(warehouseId);
advanceDetailEntity.setIncomingWarehouseName(finalWarehouseName);
});
advanceDetailService.updateBatchById(advanceDetailEntities);
advanceIds.forEach(advanceId -> {
List<String> incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId);
advanceService.updateIncomingWarehouseName(String.join(",", incomingWarehouseNames), advanceId);
});
// advanceDetailService.updatePackageStatusById("1", advanceDetailId, warehouseId, warehouseName,new Date());
// List<String> incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId);
// advanceService.updateIncomingWarehouseName(String.join(",", incomingWarehouseNames), advanceId);
//
// List<String> orderPackageCodes = new ArrayList<>();
// orderPackageCodes.add(orderPackageCode);
//存入日志
packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, finalWarehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode(), "包件" + IncomingTypeEnum.getValue(incomingType));
//2.判断包件和订单是否已经存入在库订单
boolean b = advanceService.saveOrderAndPackages(advanceDetailEntities, warehouseId);
if(b){
if (!Objects.isNull(billladingId)) {
//先判断该包件是否已经有提货记录了
List<String> noOrderPackageCodes = billladingPackageServicie.findBillladingPackages(orderPackageCodes);
if (!noOrderPackageCodes.isEmpty()) {
billladingPackageServicie.saveEntityBatch(noOrderPackageCodes, billladingId, warehouseId, incomingType);
}
}
//4.如果有托盘码
orderPackageCodes.forEach(packageCode -> {
if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) {
Map<String, Object> map = new HashMap<>();
map.put("trayType", trayType);
map.put("trayCode", trayCode);
map.put("warehouseId", warehouseId);
map.put("orderPackageCode", packageCode);
warehouseTrayTypeClient.orderScanOrderPackageCode(map);
}
});
}
try {
advanceDetailEntities.forEach(advanceDetailEntity -> {
String packageCode = advanceDetailEntity.getOrderPackageCode();
// 发送入库消息
OrderStatusDTO orderStatusDTO = new OrderStatusDTO();
// 通过包件id 查询包件
orderStatusDTO.setUnitNo(packageCode);
orderStatusDTO.setOrderNo(advanceDetailEntity.getOrderCode());
orderStatusDTO.setStatus("1");
orderStatusDTO.setOperationTime(DateUtil.now());
orderStatusDTO.setCurrentWarehouse(warehouseId.toString());
Map<String, Object> map = new HashMap<>();
map.put("messageData", JSONUtil.toJsonStr(orderStatusDTO));
rabbitTemplate.convertAndSend(RabbitConstant.HWY_ORDER_STATUS_EXCHANGE, RabbitConstant.HWY_ORDER_STATUS_ROUTING, map);
NodePushMsg nodePushMsg = NodePushMsg.builder()
.operator(AuthUtil.getNickName())
.operatorTime(new Date())
.address("在【"+ finalWarehouseName +"】入库")
.brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
.node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)
.content(Arrays.asList(PushData.builder().packageCode(packageCode).build()))
.build();
factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
});
} catch (Exception e) {
log.error("入库推送失败:{}", e);
}
}else if("1".equals(packageStatus)){
//已入库包件
if (incomingType != 1) {
log.warn("############incomingPackage: 包件已入库 orderPackageCodes={} warehouseId={}", orderPackageCodes, warehouseId);
throw new CustomerException(405,"包件"+orderPackageCodes+"已入库");
} else {
if (!Objects.isNull(billladingId)) {
//先判断该包件是否已经有提货记录了
List<String> noOrderPackageCodes = billladingPackageServicie.findBillladingPackages(orderPackageCodes);
if (!noOrderPackageCodes.isEmpty()) {
billladingPackageServicie.saveEntityBatch(noOrderPackageCodes, billladingId, warehouseId, incomingType);
}
}
//4.如果有托盘码
orderPackageCodes.forEach(packageCode -> {
if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) {
Map<String, Object> map = new HashMap<>();
map.put("trayType", trayType);
map.put("trayCode", trayCode);
map.put("warehouseId", warehouseId);
map.put("orderPackageCode", packageCode);
warehouseTrayTypeClient.orderScanOrderPackageCode(map);
}
});
}
}
}
});
// for (String packageCode : packageCodes) {
// log.info("############incomingPackage: 包件入库开始 packageCode={} billladingId={} warehouseId={}", packageCode, billladingId, warehouseId);
// //包件入库开始
// //查询包件是否有数据
// QueryWrapper<TrunklineAdvanceDetailEntity> advanceDetailQueryWrapper = new QueryWrapper<>();
// advanceDetailQueryWrapper.eq("order_package_code", packageCode);
// TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailService.getOne(advanceDetailQueryWrapper);
// if (Objects.isNull(advanceDetailEntity)) {
// log.warn("############incomingPackage: 包件不存在 packageCode={} warehouseId={}", packageCode, warehouseId);
// return Resp.scanFail(405, "包件无数据", "包件无数据");
// }
// Long advanceDetailId = advanceDetailEntity.getId();
// String packageStatus = advanceDetailEntity.getPackageStatus();
// Long advanceId = advanceDetailEntity.getAdvanceId();
// if ("1".equals(packageStatus)) {
// if (incomingType != 1) {
// log.warn("############incomingPackage: 包件已入库 packageCode={} warehouseId={}", packageCode, warehouseId);
// return Resp.scanFail(405, "包件已入库", "包件已入库");
// } else {
// if (!Objects.isNull(billladingId)) {
// //先判断该包件是否已经有提货记录了
// TrunklineBillladingPackageEntity billladingPackageEntity = billladingPackageServicie.findBillladingPackage(packageCode);
// if (Objects.isNull(billladingPackageEntity)) {
// billladingPackageServicie.saveEntity(packageCode, billladingId, warehouseId, incomingType);
// }
// }
//
// //4.如果有托盘码
// if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) {
// Map<String, Object> map = new HashMap<>();
// map.put("trayType", trayType);
// map.put("trayCode", trayCode);
// map.put("warehouseId", warehouseId);
// map.put("orderPackageCode", packageCode);
// warehouseTrayTypeClient.orderScanOrderPackageCode(map);
// }
// }
// } else {
// if (StringUtil.isBlank(warehouseName)) {
// BasicdataWarehouseEntity warehouseEntity = warehouseClient.getEntityWarehouseId(warehouseId);
// if (!Objects.isNull(warehouseEntity)) {
// warehouseName = warehouseEntity.getName();
// }
// }
//
// //1.修改暂存单包件入库状态
// advanceDetailService.updatePackageStatusById("1", advanceDetailId, warehouseId, warehouseName,new Date());
// List<String> incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId);
// advanceService.updateIncomingWarehouseName(String.join(",", incomingWarehouseNames), advanceId);
//
// List<String> orderPackageCodes = new ArrayList<>();
// orderPackageCodes.add(orderPackageCode);
// //存入日志
// packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode(), "包件" + IncomingTypeEnum.getValue(incomingType));
//
//
// //2.判断包件和订单是否已经存入在库订单
// boolean b = advanceService.saveOrderAndPackage(advanceDetailEntity, warehouseId);
//
// if (b) {
// //3.根据是否有提货单id绑定提货单
// if (!Objects.isNull(billladingId)) {
// //先判断该包件是否已经有提货记录了
// TrunklineBillladingPackageEntity billladingPackageEntity = billladingPackageServicie.findBillladingPackage(packageCode);
// if (Objects.isNull(billladingPackageEntity)) {
// billladingPackageServicie.saveEntity(packageCode, billladingId, warehouseId, incomingType);
// }
// }
//
// //4.如果有托盘码
// if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) {
// Map<String, Object> map = new HashMap<>();
// map.put("trayType", trayType);
// map.put("trayCode", trayCode);
// map.put("warehouseId", warehouseId);
// map.put("orderPackageCode", packageCode);
// warehouseTrayTypeClient.orderScanOrderPackageCode(map);
// }
// }
// try {
// // 发送入库消息
// OrderStatusDTO orderStatusDTO = new OrderStatusDTO();
// // 通过包件id 查询包件
// orderStatusDTO.setUnitNo(packageCode);
// orderStatusDTO.setOrderNo(advanceDetailEntity.getOrderCode());
// orderStatusDTO.setStatus("1");
// orderStatusDTO.setOperationTime(DateUtil.now());
// orderStatusDTO.setCurrentWarehouse(warehouseId.toString());
// Map<String, Object> map = new HashMap<>();
// map.put("messageData", JSONUtil.toJsonStr(orderStatusDTO));
// rabbitTemplate.convertAndSend(RabbitConstant.HWY_ORDER_STATUS_EXCHANGE, RabbitConstant.HWY_ORDER_STATUS_ROUTING, map);
//
// NodePushMsg nodePushMsg = NodePushMsg.builder()
// .operator(AuthUtil.getNickName())
// .operatorTime(new Date())
// .address("在【"+ warehouseName +"】入库")
// .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand()))
// .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)
// .content(Arrays.asList(PushData.builder().packageCode(packageCode).build()))
// .build();
// factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg);
// } catch (Exception e) {
// log.error("入库推送失败:{}", e);
// }
// }
// }
return R.success("入库成功");
}
@Override
public R findIncomingOrderList(InComingDTO inComingDTO) {
Integer incomingType = inComingDTO.getIncomingType();

549
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java

@ -37,11 +37,14 @@ import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -687,4 +690,550 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
return baseMapper.findListByExistsAndOrderCodeSet(orderCodeSet);
}
@Override
public boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId) {
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){
log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}",warehouseId);
throw new CustomerException(405,"仓库信息不存在");
}
TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailEntities.get(0);
String tenantId = advanceDetailEntity.getTenantId();
Long userId = AuthUtil.getUserId();
Long deptId = Func.firstLong(AuthUtil.getDeptId());
if(Objects.isNull(userId)){
userId = advanceDetailEntity.getCreateUser();
}
if(Objects.isNull(deptId)){
userId = advanceDetailEntity.getCreateDept();
}
//把advanceDetailEntities所有元素的orderCode作为key分组
Map<String, List<TrunklineAdvanceDetailEntity>> orderCodeMap = advanceDetailEntities.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getOrderCode));
Set<String> orderCodeSet = orderCodeMap.keySet();
//把advanceDetailEntities中所有元素的waybillId提取到一个Set中
Set<Long> waybillIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getWaybillId).collect(Collectors.toSet());
List<WarehouseWaybillEntity> waybillEntityList = warehouseWaybillClient.findListByWaybillIds(new ArrayList<>(waybillIdSet));
//把waybillEntityList转化成以id为key的Map
Map<String, WarehouseWaybillEntity> waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity()));
//提取出advanceDetailEntities所有元素的advanceId存入Set
Set<Long> advanceIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getAdvanceId).collect(Collectors.toSet());
List<TrunklineAdvanceEntity> advanceEntityList = findListByIds(new ArrayList<>(advanceIdSet));
Map<String,TrunklineAdvanceEntity> advanceEntityMap = new HashMap<>();
if(advanceEntityList.isEmpty()){
advanceEntityMap = advanceEntityList.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getOrderCode, Function.identity()));
}
List<DistributionStockArticleEntity> stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId);
Map<String, DistributionStockArticleEntity> stockArticleMap = new HashMap<>();
if(!stockArticleEntities.isEmpty()){
stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity()));
}
List<DistributionParcelListEntity> parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(orderCodeSet,warehouseId);
Map<String, DistributionParcelListEntity> parcelListMap = new HashMap<>();
if(!parcelListEntities.isEmpty()){
parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity()));
}
Set<String> hasOrderPackageCodes = parcelListMap.keySet();
Map<String, DistributionStockArticleEntity> finalStockArticleMap = stockArticleMap;
Map<String, DistributionParcelListEntity> finalParcelListMap = parcelListMap;
Map<String, TrunklineAdvanceEntity> finalAdvanceEntityMap = advanceEntityMap;
Long finalUserId = userId;
Date date = new Date();
List<DistributionStockArticleEntity> addStockArticleEntities = new ArrayList<>();
List<DistributionStockArticleEntity> updateStockArticleEntities = new ArrayList<>();
orderCodeSet.forEach(orderCode -> {
int total = baseMapper.getAllTotalNum(orderCode);
DistributionStockArticleEntity stockArticleEntity = finalStockArticleMap.get(orderCode);
if(Objects.isNull(stockArticleEntity)){
TrunklineAdvanceEntity advanceEntity = finalAdvanceEntityMap.get(orderCode);
if(!Objects.isNull(advanceEntity)){
String waybillNo = advanceEntity.getWaybillNo();
stockArticleEntity = new DistributionStockArticleEntity();
stockArticleEntity.setTenantId(tenantId);
stockArticleEntity.setCreateUser(finalUserId);
stockArticleEntity.setUpdateUser(finalUserId);
stockArticleEntity.setCreateDept(deptId);
stockArticleEntity.setOrderCode(orderCode);
stockArticleEntity.setServiceNumber(advanceEntity.getServiceNum());
stockArticleEntity.setWaybillNumber(waybillNo);
stockArticleEntity.setTotalNumber(total);
stockArticleEntity.setHandQuantity(0);
// stockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID
stockArticleEntity.setWarehouse(warehouseEntity.getName());
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 = waybillEntityMap.get(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);
addStockArticleEntities.add(stockArticleEntity);
}else{
stockArticleEntity.setTotalNumber(total);
updateStockArticleEntities.add(stockArticleEntity);
}
}
});
stockArticleClient.updateByBatchId(updateStockArticleEntities);
List<DistributionStockArticleEntity> returnStockArticleEntities = stockArticleClient.addReturnList(addStockArticleEntities);
returnStockArticleEntities.addAll(updateStockArticleEntities);
Map<String,DistributionStockArticleEntity> saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity()));
List<DistributionParcelListEntity> parcelListEntityList = new ArrayList<>();
orderCodeMap.keySet().forEach(orderCode->{
DistributionStockArticleEntity stockArticleEntity = saMap.get(orderCode);
if(!Objects.isNull(stockArticleEntity)){
Long orderId = stockArticleEntity.getId();
List<TrunklineAdvanceDetailEntity> adList = orderCodeMap.get(orderCode);
adList.forEach(ad->{
String orderPackageCode = ad.getOrderPackageCode();
if(!hasOrderPackageCodes.contains(orderPackageCode)){
String trainNumber = ad.getTrainNumber();
DistributionParcelListEntity parcelList = new DistributionParcelListEntity();
parcelList.setCreateUser(finalUserId);
parcelList.setUpdateUser(finalUserId);
parcelList.setCreateDept(deptId);
parcelList.setTenantId(tenantId);
parcelList.setWarehouse(warehouseEntity.getName());
parcelList.setWarehouseId(warehouseId);
parcelList.setIsTransfer(1);
String waybillNo = ad.getWaybillNo();
if(StringUtil.isNotBlank(waybillNo)){
WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo);
if(!Objects.isNull(waybillEntity)){
parcelList.setWaybillId(waybillEntity.getId());
parcelList.setWaybillNumber(waybillEntity.getWaybillNo());
parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId());
parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName());
Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId();
parcelList.setAcceptWarehouseId(destinationWarehouseId);
parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName());
if(warehouseId.equals(destinationWarehouseId)){
parcelList.setIsTransfer(0);
}
}
}
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.setTrainNumber(trainNumber);
parcelList.setAdvanceId(ad.getAdvanceId());
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);
}
});
}
});
parcelListClient.addBatch(parcelListEntityList);
// String orderPackageCode = advanceDetailEntity.getOrderPackageCode();
// String orderCode = advanceDetailEntity.getOrderCode();
// Long advanceId = advanceDetailEntity.getAdvanceId();
// String tenantId = advanceDetailEntity.getTenantId();
// log.info("############saveOrderAndPackage: 保存订单和包件信息 orderPackageCode={}",orderPackageCode);
//
// BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
// if(Objects.isNull(warehouseEntity)){
// log.warn("############saveOrderAndPackage: 仓库信息不存在warehouseId={}",warehouseId);
// throw new CustomerException(405,"仓库信息不存在");
// }
//
// //1.判断包件是否已经存在
// DistributionParcelListEntity parcelListEntity = parcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId);
// if(!Objects.isNull(parcelListEntity)){
// log.warn("############saveOrderAndPackage: 包件信息已存在 orderPackageCode={} warehouseId={}",orderPackageCode,warehouseId);
// return true;
// }
//
// TrunklineAdvanceEntity advanceEntity = getById(advanceId);
// if(Objects.isNull(advanceEntity)){
// log.warn("############saveOrderAndPackage: 暂存单信息不存在 advanceId={} warehouseId={}",advanceId,warehouseId);
// throw new CustomerException(405,"暂存单信息不存在");
// }
//
// Long userId = AuthUtil.getUserId();
// Long deptId = null;
// String deptIds = AuthUtil.getDeptId();
// String[] split = deptIds.split(",");
// if(Objects.isNull(userId)){
// userId = advanceDetailEntity.getCreateUser();
// }
// if(CollUtil.isEmpty(Arrays.asList(split))){
// deptId = Long.parseLong(split[0]);
// }
// if(Objects.isNull(deptId)){
// userId = advanceDetailEntity.getCreateDept();
// }
//
// //2.查询订单信息
// int total = baseMapper.getAllTotalNum(orderCode);
//
// Date date = new Date();
// Long orderId = null;
// DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
// if(Objects.isNull(stockArticleEntity)){
// log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息");
// //订单信息为空
// String waybillNo = advanceEntity.getWaybillNo();
//
// stockArticleEntity = new DistributionStockArticleEntity();
// stockArticleEntity.setTenantId(tenantId);
// 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(TenantNum.HUITONGCODE);// 对应租户ID
// stockArticleEntity.setWarehouse(warehouseEntity.getName());
// 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,"订单信息有误");
// }
// log.info("#############saveOrderAndPackage: 订单信息保存成功 orderId={}",orderId);
//
// //保存包件信息
// DistributionParcelListEntity parcelList = new DistributionParcelListEntity();
// parcelList.setCreateUser(userId);
// parcelList.setUpdateUser(userId);
// parcelList.setCreateDept(deptId);
// parcelList.setTenantId(tenantId);
// parcelList.setWarehouse(warehouseEntity.getName());
// parcelList.setWarehouseId(warehouseId);
// parcelList.setIsTransfer(1);
// 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());
// Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId();
// parcelList.setAcceptWarehouseId(destinationWarehouseId);
// parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName());
// if(warehouseId.equals(destinationWarehouseId)){
// parcelList.setIsTransfer(0);
// }
// }
// }
// parcelList.setConditions(1);
// parcelList.setOrderPackageCode(advanceDetailEntity.getOrderPackageCode());
// 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.setTrainNumber(advanceEntity.getTrainNumber());
// 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());
// Long orderPackageId = parcelListClient.addReturnId(parcelList);
// if(!Objects.isNull(orderPackageId)){
// log.info("################saveOrderAndPackage: 包件信息保存成功 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode());
// //1.修改订单在库件数和最后入库时间和入库状态
//
//// List<DistributionParcelListEntity> parcelListEntityList = parcelListClient.findEntityListByOrderCode(orderCode, warehouseId);
//// int size = parcelListEntityList.size();
//// Integer totalNumber = stockArticleEntity.getTotalNumber();//总件数
//// Integer handQuantity = stockArticleEntity.getHandQuantity();//在库件数
//// Integer incomingNum = stockArticleEntity.getIncomingNum();//入库件数
////
//// if(size == 1){
//// stockArticleEntity.setWarehouseEntryTime(date);
//// stockArticleEntity.setWarehouseEntryTimeEnd(new Date());
//// stockArticleEntity.setHandQuantity(handQuantity+1);
//// stockArticleEntity.setIncomingNum(incomingNum+1);
//// }else{
//// stockArticleEntity.setWarehouseEntryTimeEnd(new Date());
//// stockArticleEntity.setHandQuantity(handQuantity+1);
//// stockArticleEntity.setIncomingNum(incomingNum+1);
//// }
////
//// if(incomingNum+1 < totalNumber){
//// stockArticleEntity.setOrderStatus("10");
//// }else{
//// stockArticleEntity.setOrderStatus("20");
//// }
//// stockArticleClient.saveOrUpdate(stockArticleEntity);
// }
// log.info("#############saveOrderAndPackage: 订单包件信息保存完成 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode());
return true;
}
}

287
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingPackageServiceImpl.java

@ -12,18 +12,21 @@ import com.logpm.trunkline.vo.TrunklineBillladingPackageVO;
import com.logpm.warehouse.entity.WarehouseWaybillEntity;
import com.logpm.warehouse.feign.IWarehouseWaybillClient;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.IncomingTypeEnum;
import org.springblade.common.constant.WaybillStatusEnum;
import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -41,6 +44,8 @@ public class TrunklineBillladingPackageServiceImpl extends BaseServiceImpl<Trunk
@Autowired
private ITrunklineWaybillOrderService trunklineWaybillOrderService;
@Autowired
private ITrunklineAdvanceService trunklineAdvanceService;
@Autowired
private IWarehouseWaybillClient warehouseWaybillClient;
@Autowired
private ITrunklineWaybillTrackService trunklineWaybillTrackService;
@ -176,4 +181,280 @@ public class TrunklineBillladingPackageServiceImpl extends BaseServiceImpl<Trunk
return baseMapper.findBillladingPackage(packageCode);
}
@Override
public List<String> findBillladingPackages(List<String> orderPackageCodes) {
List<String> billladingPackages = baseMapper.findBillladingPackages(orderPackageCodes);
orderPackageCodes.removeAll(billladingPackages);
return orderPackageCodes;
}
@Override
public void saveEntityBatch(List<String> noOrderPackageCodes, Long billladingId, Long warehouseId, Integer incomingType) {
log.info("################saveEntityBatch: 包件绑定提货单 noOrderPackageCodes={} billladingId={}",noOrderPackageCodes,billladingId);
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){
log.warn("############saveEntityBatch: 仓库信息不存在warehouseId={}",warehouseId);
throw new CustomerException(405,"仓库信息不存在");
}
TrunklineBillladingEntity trunklineBillladingEntity = trunklineBillladingService.getById(billladingId);
if(Objects.isNull(trunklineBillladingEntity)){
log.warn("############saveEntityBatch: 提货单不存在 billladingId={}",billladingId);
throw new CustomerException(405,"提货单不存在");
}
QueryWrapper<TrunklineAdvanceDetailEntity> advanceDetailEntityQueryWrapper = new QueryWrapper<>();
advanceDetailEntityQueryWrapper.in("order_package_code",noOrderPackageCodes)
.eq("warehouse_id",warehouseId);
List<TrunklineAdvanceDetailEntity> advanceDetailList = trunklineAdvanceDetailService.list(advanceDetailEntityQueryWrapper);
if(advanceDetailList.isEmpty()){
log.warn("############saveEntityBatch: 包件信息不存在 noOrderPackageCodes={}",noOrderPackageCodes);
throw new CustomerException(405,"包件信息不存在");
}
List<TrunklineBillladingPackageEntity> billladingPackageEntities = new ArrayList<>();
Set<Long> advanceIdsSet = new HashSet<>();
advanceDetailList.forEach(advanceDetailEntity -> {
//1.保存入库包件明细
advanceIdsSet.add(advanceDetailEntity.getAdvanceId());
TrunklineBillladingPackageEntity billladingPackageEntity = new TrunklineBillladingPackageEntity();
billladingPackageEntity.setWarehouseId(warehouseId);
billladingPackageEntity.setWarehouseName(warehouseEntity.getName());
billladingPackageEntity.setOrderPackageCode(advanceDetailEntity.getOrderPackageCode());
billladingPackageEntity.setBillladingId(billladingId);
billladingPackageEntity.setCreateUserName(AuthUtil.getNickName());
billladingPackageEntity.setIncomingType(incomingType);
billladingPackageEntities.add(billladingPackageEntity);
});
saveBatch(billladingPackageEntities);
QueryWrapper<TrunklineAdvanceEntity> advanceEntityQueryWrapper = new QueryWrapper<>();
advanceEntityQueryWrapper.in("id",advanceIdsSet)
.eq("waybill_status","1");
List<TrunklineAdvanceEntity> advanceEntities = trunklineAdvanceService.list(advanceEntityQueryWrapper);
//把advanceEntities所有元素的waybillNo放入一个Set<String>
Set<String> waybillNoSet = advanceEntities.stream().map(TrunklineAdvanceEntity::getWaybillNo).collect(Collectors.toSet());
List<WarehouseWaybillEntity> waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet));
//把waybillEntityList转化成waybillNo为key的Map
Map<String, WarehouseWaybillEntity> waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity()));
//把advanceEntities转成以id为key的Map
Map<Long, TrunklineAdvanceEntity> advanceEntityMap = advanceEntities.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getId, Function.identity()));
//把advanceDetailList中的所有元素的advanceId分组
Map<Long, List<TrunklineAdvanceDetailEntity>> advanceIdGroupedEntities = advanceDetailList.stream()
.collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getAdvanceId));
Map<String,Integer> waybillNoMNumMap = new HashMap<>();
advanceEntityMap.keySet().forEach(advanceId -> {
TrunklineAdvanceEntity advanceEntity = advanceEntityMap.get(advanceId);
String waybillNo = advanceEntity.getWaybillNo();
if(StringUtil.isNotBlank(waybillNo)){
List<TrunklineAdvanceDetailEntity> advanceDetailEntities = advanceIdGroupedEntities.get(advanceId);
int size = advanceDetailEntities.size();
WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo);
Integer stockCount = waybillEntity.getStockCount();
Integer totalCount = waybillEntity.getTotalCount();
if(Objects.isNull(stockCount)){
stockCount = 0;
}
int diff = 0;
int all = stockCount + size;
if(all > totalCount){
waybillEntity.setStockCount(totalCount);
diff = totalCount - stockCount;
}else{
waybillEntity.setStockCount(all);
diff = size;
}
Integer integer = waybillNoMNumMap.get(waybillNo);
if(Objects.isNull(integer)){
waybillNoMNumMap.put(waybillNo,diff);
}else{
waybillNoMNumMap.put(waybillNo,diff+integer);
}
waybillEntityMap.put(waybillNo,waybillEntity);
}
});
QueryWrapper<TrunklineBillladingWaybillEntity> billladingWaybillEntityQueryWrapper = new QueryWrapper<>();
billladingWaybillEntityQueryWrapper.in("waybill_no",waybillNoSet)
.eq("billlading_id",billladingId)
.eq("is_deleted",0);
List<TrunklineBillladingWaybillEntity> billladingWaybillEntityList = trunklineBillladingWaybillService.list(billladingWaybillEntityQueryWrapper);
//把billladingWaybillEntityList转化成waybillNo为key的Map
Map<String, TrunklineBillladingWaybillEntity> billladingWaybillEntityMap = billladingWaybillEntityList.stream().collect(Collectors.toMap(TrunklineBillladingWaybillEntity::getWaybillNo, Function.identity()));
List<TrunklineBillladingWaybillEntity> addList = new ArrayList<>();
List<TrunklineBillladingWaybillEntity> updateList = new ArrayList<>();
final TrunklineBillladingWaybillEntity[] noWaybillData = {trunklineBillladingWaybillService.findNoWaybillNoData(billladingId)};
waybillNoSet.forEach(waybillNo -> {
Integer integer = waybillNoMNumMap.get(waybillNo);
TrunklineBillladingWaybillEntity billladingWaybillEntity = billladingWaybillEntityMap.get(waybillNo);
if(Objects.isNull(billladingWaybillEntity)){
//查询是否有一条无运单的数据
if(Objects.isNull(noWaybillData[0])){
noWaybillData[0] = new TrunklineBillladingWaybillEntity();
noWaybillData[0].setWarehouseId(warehouseId);
noWaybillData[0].setWarehouseName(warehouseEntity.getName());
noWaybillData[0].setBillladingId(billladingId);
noWaybillData[0].setBilladingCode(trunklineBillladingEntity.getBillladingCode());
noWaybillData[0].setWaybillNo("————");
noWaybillData[0].setRealNum(integer);
noWaybillData[0].setRealWeight(BigDecimal.ZERO);
noWaybillData[0].setRealVolume(BigDecimal.ZERO);
}else{
Integer realNum = noWaybillData[0].getRealNum();
noWaybillData[0].setRealNum(realNum+integer);
}
}else{
Integer realNum = billladingWaybillEntity.getRealNum();
billladingWaybillEntity.setRealNum(realNum + integer);
updateList.add(billladingWaybillEntity);
}
});
addList.add(noWaybillData[0]);
trunklineBillladingWaybillService.saveBatch(addList);
trunklineBillladingWaybillService.updateBatchById(updateList);
TrunklineBillladingEntity billladingEntity = trunklineBillladingService.getById(billladingId);
if(!Objects.isNull(billladingEntity)){
int realNum = billladingEntity.getRealNum();
Integer all = waybillNoMNumMap.values().stream().reduce(Integer::sum).get();
billladingEntity.setRealNum(realNum+all);
trunklineBillladingService.updateById(billladingEntity);
}
waybillEntityMap.keySet().forEach(waybillNo -> {
WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo);
if(Objects.isNull(waybillEntity)){
Integer totalCount = waybillEntity.getTotalCount();
Integer stockCount = waybillEntity.getStockCount();
if(stockCount.equals(totalCount)){
waybillEntity.setWaybillStatus(WaybillStatusEnum.RUKU.getCode());
try{
TrunklineWaybillTrackEntity waybillTrackEntity = new TrunklineWaybillTrackEntity();
waybillTrackEntity.setWarehouseId(warehouseId);
waybillTrackEntity.setWarehouseName(warehouseEntity.getName());
waybillTrackEntity.setWaybillId(waybillEntity.getId());
waybillTrackEntity.setWaybillNo(waybillEntity.getWaybillNo());
waybillTrackEntity.setTrackType("20");
waybillTrackEntity.setRefer("已入库");
waybillTrackEntity.setOperationRemark("运单入库:"+stockCount+"/"+totalCount+",入库类型:【"+ IncomingTypeEnum.getValue(incomingType) +"】,入库时间:"+ CommonUtil.dateToString(new Date()));
trunklineWaybillTrackService.save(waybillTrackEntity);
}catch (Exception e){
log.warn("#################updateBillladingWaybillNum: 存入日志失败");
}
}else{
waybillEntity.setWaybillStatus(WaybillStatusEnum.BUFENRUKU.getCode());
}
}
});
List<WarehouseWaybillEntity> warehouseWaybillEntities = new ArrayList<>(waybillEntityMap.values());
warehouseWaybillClient.updateList(warehouseWaybillEntities);
//根据提货单id重新计算每个运单的费用
trunklineBillladingWaybillService.updateBillladingFeeByBillladingId(trunklineBillladingEntity);
// QueryWrapper<TrunklineBillladingPackageEntity> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("order_package_code",orderPackageCode);
// TrunklineBillladingPackageEntity billladingPackageEntity = baseMapper.selectOne(queryWrapper);
// if(!Objects.isNull(billladingPackageEntity)){
// log.warn("####################saveEntity: 包件已入库 orderPackageCode={}",orderPackageCode);
// throw new CustomerException(405,"包件已入库");
// }
//
//
//
// //2.判断运单是否需要加上数量
// List<TrunklineWaybillOrderEntity> ls = trunklineBillladingWaybillService.findWaybillOrderByBillladingId(billladingId,advanceId);
// int size = ls.size();
// if(size != 0){
// TrunklineWaybillOrderEntity trunklineWaybillOrderEntity = ls.get(0);
// Long waybillId = trunklineWaybillOrderEntity.getWaybillId();
// //查询该运单对应的所有订单的一个总数量
// WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillId(waybillId);
// Integer allTotalNum = waybillEntity.getTotalCount();
// //查询运单已提货的数量
// Integer finishNum = waybillEntity.getStockCount();
//
// //计算数量是否正确
// if(finishNum+1 > allTotalNum){
// log.warn("####################saveEntity: 运单提货已完成,无法增加提货数量 finishNum={} allTotalNum={}",finishNum,allTotalNum);
// throw new CustomerException(405,"运单提货已完成,无法增加提货数量");
// }
//
// TrunklineBillladingWaybillEntity billladingWaybillEntity = trunklineBillladingWaybillService.findEntityByWaybillIdAndBillladingId(waybillId,billladingId);
// if(Objects.isNull(billladingWaybillEntity)){
// log.warn("####################saveEntity: 提货运单信息有误 waybillId={} billladingId={}",waybillId,billladingId);
// throw new CustomerException(405,"提货运单信息有误");
// }
// Integer realNum = billladingWaybillEntity.getRealNum();
// billladingWaybillEntity.setRealNum(realNum+1);
// trunklineBillladingWaybillService.updateById(billladingWaybillEntity);
// waybillEntity.setStockCount(finishNum+1);
//
// if(allTotalNum.equals(waybillEntity.getStockCount())){
// waybillEntity.setWaybillStatus("20");
// try{
// TrunklineWaybillTrackEntity waybillTrackEntity = new TrunklineWaybillTrackEntity();
// waybillTrackEntity.setWarehouseId(warehouseId);
// waybillTrackEntity.setWarehouseName(warehouseEntity.getName());
// waybillTrackEntity.setWaybillId(waybillId);
// waybillTrackEntity.setWaybillNo(waybillEntity.getWaybillNo());
// waybillTrackEntity.setTrackType("20");
// waybillTrackEntity.setRefer("已入库");
// waybillTrackEntity.setOperationRemark("运单入库:"+waybillEntity.getStockCount()+"/"+allTotalNum+",入库类型:【批量入库】,入库时间:"+ CommonUtil.dateToString(new Date()));
// trunklineWaybillTrackService.save(waybillTrackEntity);
// }catch (Exception e){
// log.warn("#################updateBillladingWaybillNum: 存入日志失败");
// }
// }else{
// waybillEntity.setWaybillStatus("10");
// }
//
// warehouseWaybillClient.updateEntity(waybillEntity);
//
// }else{
// //查询是否有一条无运单的数据
// TrunklineBillladingWaybillEntity noWaybillData = trunklineBillladingWaybillService.findNoWaybillNoData(billladingId);
// if(Objects.isNull(noWaybillData)){
// noWaybillData = new TrunklineBillladingWaybillEntity();
// noWaybillData.setWarehouseId(warehouseId);
// noWaybillData.setWarehouseName(warehouseEntity.getName());
// noWaybillData.setBillladingId(billladingId);
// noWaybillData.setBilladingCode(trunklineBillladingEntity.getBillladingCode());
// noWaybillData.setWaybillNo("————");
// noWaybillData.setRealNum(1);
// noWaybillData.setRealWeight(BigDecimal.ZERO);
// noWaybillData.setRealVolume(BigDecimal.ZERO);
// trunklineBillladingWaybillService.save(noWaybillData);
// }else{
// Integer realNum = noWaybillData.getRealNum();
// noWaybillData.setRealNum(realNum+1);
// trunklineBillladingWaybillService.updateById(noWaybillData);
// }
// }
//
// int rn = trunklineBillladingEntity.getRealNum();
// trunklineBillladingEntity.setRealNum(rn+1);
// trunklineBillladingService.updateById(trunklineBillladingEntity);
}
}

Loading…
Cancel
Save