|
|
|
@ -18,7 +18,6 @@ package com.logpm.distribution.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
@ -33,26 +32,72 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
|
|
|
|
import com.logpm.distribution.bean.Resp; |
|
|
|
|
import com.logpm.distribution.dto.DistributionBillLadingExcelDTO; |
|
|
|
|
import com.logpm.distribution.dto.DistributionParcelListDTO; |
|
|
|
|
import com.logpm.distribution.dto.DistributionStockListDTO; |
|
|
|
|
import com.logpm.distribution.dto.DistrilbutionBillLadingDTO; |
|
|
|
|
import com.logpm.distribution.dto.OrderStatusDTO; |
|
|
|
|
import com.logpm.distribution.dto.app.BillLadingAppDTO; |
|
|
|
|
import com.logpm.distribution.dto.DistributionBillLadingExcelDTO; |
|
|
|
|
import com.logpm.distribution.entity.*; |
|
|
|
|
import com.logpm.distribution.entity.DisStockListDetailEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionBillLadingScanEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionDeliveryChargeEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionDeliveryDetailsEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionParcelListEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionParcelNumberEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionPrintEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionReservationZeroPackageEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockArticleEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockListEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockupEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockupInfoEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistributionStockupScanEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistrilbutionBillLadingEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistrilbutionBillPackageEntity; |
|
|
|
|
import com.logpm.distribution.entity.DistrilbutionBillStockEntity; |
|
|
|
|
import com.logpm.distribution.excel.DistributionBillInventoryExcel; |
|
|
|
|
import com.logpm.distribution.excel.DistributionBillOrderExcel; |
|
|
|
|
import com.logpm.distribution.excel.DistributionBillOrderPackExcel; |
|
|
|
|
import com.logpm.distribution.excel.DistrilbutionBillLadingExcel; |
|
|
|
|
import com.logpm.distribution.mapper.DistributionStockListMapper; |
|
|
|
|
import com.logpm.distribution.mapper.DistrilbutionBillLadingMapper; |
|
|
|
|
import com.logpm.distribution.service.*; |
|
|
|
|
import com.logpm.distribution.vo.*; |
|
|
|
|
import com.logpm.distribution.vo.app.*; |
|
|
|
|
import com.logpm.distribution.service.IDisStockListDetailService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionAsyncService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionBillLadingScanService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionDeliveryChargeService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionDeliveryDetailsService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionParcelListService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionParcelNumberService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionPrintService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionReservationService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionReservationZeroPackageService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockArticleService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockListService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockupInfoService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockupScanService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockupService; |
|
|
|
|
import com.logpm.distribution.service.IDistrilbutionBillLadingService; |
|
|
|
|
import com.logpm.distribution.service.IDistrilbutionBillPackageService; |
|
|
|
|
import com.logpm.distribution.service.IDistrilbutionBillStockService; |
|
|
|
|
import com.logpm.distribution.vo.DistributionDeliveryDetailsVO; |
|
|
|
|
import com.logpm.distribution.vo.DistributionParcelNumberVO; |
|
|
|
|
import com.logpm.distribution.vo.DistributionStockArticleVO; |
|
|
|
|
import com.logpm.distribution.vo.DistributionStockListVO; |
|
|
|
|
import com.logpm.distribution.vo.DistributionStockupOrderListVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillLadingAppVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillLadingDetailsVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillLadingOwnVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillLadingVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillLadingViewVO; |
|
|
|
|
import com.logpm.distribution.vo.DistrilbutionBillStockVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionAppBillLadingDetailVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionAppBillLadingOrderMainVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionAppBillLadingOrderVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionAppBillLadingZeroOrderVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionAppBillLadingZeroVO; |
|
|
|
|
import com.logpm.distribution.vo.app.DistrilbutionBillLadingInventoryAppVO; |
|
|
|
|
import com.logpm.distribution.wrapper.DistributionStockArticleWrapper; |
|
|
|
|
import com.logpm.factory.mt.dto.MtReceiveContentDTO; |
|
|
|
|
import com.logpm.factory.mt.dto.MtReceiveDTO; |
|
|
|
|
import com.logpm.factory.mt.dto.MtReceiveImagesDTO; |
|
|
|
|
import com.logpm.factorydata.enums.BrandEnums; |
|
|
|
|
import com.logpm.factorydata.util.FactoryDataMessageSender; |
|
|
|
|
import com.logpm.factorydata.vo.NodePushMsg; |
|
|
|
@ -100,7 +145,6 @@ import org.springblade.system.feign.IUserClient;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.context.annotation.Condition; |
|
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@ -109,7 +153,18 @@ import javax.annotation.Resource;
|
|
|
|
|
import java.io.Serializable; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.ListIterator; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -398,7 +453,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
.eq(DistributionDeliveryDetailsEntity::getBillLadingId, distrilbutionBillLading.getId()) |
|
|
|
|
.ne(DistributionDeliveryDetailsEntity::getInventoryStatus, "2") |
|
|
|
|
); |
|
|
|
|
Map<Long, List<DistributionDeliveryDetailsEntity>> map = null; |
|
|
|
|
Map<Long, List<DistributionDeliveryDetailsEntity>> map = new HashMap<>(); |
|
|
|
|
if (!listDetails.isEmpty()) { |
|
|
|
|
map = listDetails.stream().collect(Collectors.groupingBy(DistributionDeliveryDetailsEntity::getStockListId)); |
|
|
|
|
} |
|
|
|
@ -636,6 +691,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), distrilbutionBillPackageEntity.getOrderPackageCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
logs.add(js); |
|
|
|
|
} |
|
|
|
|
sendFactoryPlan(packageMap.get(Long.parseLong(s)),myCurrentWarehouse, distrilbutionBillLading); |
|
|
|
|
} else { |
|
|
|
|
//没有进行包件的勾选,默认添加所有可用包件至计划下
|
|
|
|
|
List<DistributionParcelListEntity> parcelListEntities = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda() |
|
|
|
@ -656,6 +712,8 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), parcelListEntity.getOrderPackageCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
logs.add(js); |
|
|
|
|
} |
|
|
|
|
// 推送工厂
|
|
|
|
|
sendFactoryPlan(parcelListEntities, myCurrentWarehouse, distrilbutionBillLading); |
|
|
|
|
} else { |
|
|
|
|
log.error("#####################自提计划订单无可用包件:{}", s); |
|
|
|
|
throw new ServiceException(stockArticleEntity.getOrderCode() + "订单无可用包件!!!"); |
|
|
|
@ -681,6 +739,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), parcelListEntity.getOrderPackageCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
logs.add(js); |
|
|
|
|
} |
|
|
|
|
sendFactoryPlan(parcelListEntities, myCurrentWarehouse, distrilbutionBillLading); |
|
|
|
|
} else { |
|
|
|
|
log.error("#####################自提计划订单无可用包件:{}", s); |
|
|
|
|
throw new ServiceException(stockArticleEntity.getOrderCode() + "订单无可用包件!!!"); |
|
|
|
@ -861,6 +920,44 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void sendFactoryPlan(List<DistributionParcelListEntity> parcelListEntities, BasicdataWarehouseEntity myCurrentWarehouse, DistrilbutionBillLadingDTO distrilbutionBillLading) { |
|
|
|
|
// 包件按品牌分组
|
|
|
|
|
try { |
|
|
|
|
Map<String, List<DistributionParcelListEntity>> parcelListMap = parcelListEntities.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getBrandName)); |
|
|
|
|
if(CollUtil.isNotEmpty(parcelListMap)){ |
|
|
|
|
for (Map.Entry<String, List<DistributionParcelListEntity>> entry : parcelListMap.entrySet()) { |
|
|
|
|
String key = entry.getKey(); |
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.put("trainNumber", distrilbutionBillLading.getPickupBatch()); |
|
|
|
|
jsonObject.put("receiver", distrilbutionBillLading.getConsignee()); |
|
|
|
|
jsonObject.put("receiveAddr", myCurrentWarehouse.getName()); |
|
|
|
|
jsonObject.put("receiveTel", distrilbutionBillLading.getCustomerTelephone()); |
|
|
|
|
jsonObject.put("planDeliveryDate", DateUtil.formatDateTime(distrilbutionBillLading.getPickUpTime())); |
|
|
|
|
List<DistributionParcelListEntity> listEntities = entry.getValue(); |
|
|
|
|
NodePushMsg msg = new NodePushMsg(); |
|
|
|
|
msg.setNode(WorkNodeEnums.PLAN_BILLOFLADING); |
|
|
|
|
msg.setBrand(BrandEnums.getByValue(key)); |
|
|
|
|
msg.setOperator(AuthUtil.getNickName()); |
|
|
|
|
msg.setOperatorTime(new Date()); |
|
|
|
|
msg.setMain(jsonObject.toString()); |
|
|
|
|
msg.setContent(listEntities.stream().map(item->{ |
|
|
|
|
return PushData.builder() |
|
|
|
|
.orderCode(item.getOrderCode()) |
|
|
|
|
.packageCode(item.getOrderPackageCode()) |
|
|
|
|
.warehouseName(myCurrentWarehouse.getName()) |
|
|
|
|
.waybillNumber(item.getWaybillNumber()) |
|
|
|
|
.build(); |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); |
|
|
|
|
factoryDataMessageSender.sendNodeDataByBrand(msg); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("推送签收数据给工厂失败 {}", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
private static DistrilbutionBillPackageEntity getDistrilbutionBillPackageEntity(DistrilbutionBillLadingDTO distrilbutionBillLading, DistributionParcelListEntity parcelListEntity) { |
|
|
|
|
DistrilbutionBillPackageEntity billPackageEntity = new DistrilbutionBillPackageEntity(); |
|
|
|
@ -1583,6 +1680,13 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
.in("id", collect) |
|
|
|
|
.set("order_package_reservation_status", OrderPackageReservationStatusConstant.yiyueyue.getValue()) |
|
|
|
|
); |
|
|
|
|
// 推送工厂
|
|
|
|
|
if(CollUtil.isNotEmpty(collect)){ |
|
|
|
|
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.listByIds(collect); |
|
|
|
|
if(CollUtil.isNotEmpty(distributionParcelListEntities)){ |
|
|
|
|
sendFactoryPlan(distributionParcelListEntities, warehouse, distrilbutionBillLading); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
@ -1600,7 +1704,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.listByIds(collect); |
|
|
|
|
for (DistributionParcelListEntity distributionParcelListEntity : distributionParcelListEntities) { |
|
|
|
|
String content = "包件在" + warehouse.getName() + "由" + AuthUtil.getNickName() + "取消计划自提,操作方式:订单取消勾选包件,自提批次号:" + pickupBatch; |
|
|
|
|
JSONObject js = handleLogJSONObject(warehouse, AuthUtil.getUser(), distributionParcelListEntity.getOrderPackageCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
JSONObject js = handleLogJSONObject(warehouse, AuthUtil.getUser(), distributionParcelListEntity.getOrderPackageCode(), content, WorkNodeEnums.CANCEL_BILLOFLADING.getCode()); |
|
|
|
|
aaa.add(js); |
|
|
|
|
} |
|
|
|
|
packageIds.addAll(collect); |
|
|
|
@ -1813,7 +1917,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
if (!list.isEmpty()) { |
|
|
|
|
for (DistrilbutionBillPackageEntity billPackageEntity : list) { |
|
|
|
|
String content = "包件在" + myCurrentWarehouse.getName() + "由" + AuthUtil.getNickName() + "取消计划自提,操作方式:移除订单,自提批次号:" + pickupBatch; |
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), billPackageEntity.getPacketBarCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), billPackageEntity.getPacketBarCode(), content, WorkNodeEnums.CANCEL_BILLOFLADING.getCode()); |
|
|
|
|
aaa.add(js); |
|
|
|
|
|
|
|
|
|
billPackageEntity.setPacketBarStatus(2); |
|
|
|
@ -1908,6 +2012,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
JSONObject js = handleLogJSONObject(myCurrentWarehouse, AuthUtil.getUser(), billPackageEntity.getPacketBarCode(), content, WorkNodeEnums.PLAN_BILLOFLADING.getCode()); |
|
|
|
|
aaa.add(js); |
|
|
|
|
}); |
|
|
|
|
sendFactoryPlan(parcelListEntities, myCurrentWarehouse, distrilbutionBillLading); |
|
|
|
|
//修改包件数量为预约状态
|
|
|
|
|
List<Long> collect = parcelListEntities.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()); |
|
|
|
|
distributionParcelListService.update(Wrappers.<DistributionParcelListEntity>update() |
|
|
|
|