Browse Source

1.干线-批量导入 逻辑更新

2.修复配送保存创建部门bug
dist.1.3.0
zhenghaoyu 11 months ago
parent
commit
826c92bc6c
  1. 3
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java
  2. 3
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineCarsLoadScanVO.java
  3. 23
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java
  4. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java
  5. 63
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/ExecutorConfig.java
  6. 1
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java
  7. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java
  8. 18
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml
  9. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java
  10. 12
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml
  11. 14
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IAsyncService.java
  12. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java
  13. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java
  14. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsSignLogService.java
  15. 26
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java
  16. 220
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java
  17. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java
  18. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java
  19. 194
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java
  20. 33
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsSignLogServiceImpl.java

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

@ -152,4 +152,7 @@ public interface IDistributionParcelListClient {
@PostMapping(API_PREFIX+"/updatePackageStatus")
void updatePackageStatus(@RequestParam List<String> orderPackageCodes, @RequestParam Long warehouseId, @RequestParam String packageStatus);
@PostMapping(API_PREFIX+"/updateList")
void updateList(@RequestBody List<DistributionParcelListEntity> updateParcelList);
}

3
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineCarsLoadScanVO.java

@ -5,4 +5,7 @@ import lombok.Data;
@Data
public class TrunklineCarsLoadScanVO extends TrunklineCarsLoadScanEntity {
private Long signOrderId;
}

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

@ -39,10 +39,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -346,4 +343,22 @@ public class DistributionParcelListClient implements IDistributionParcelListClie
}
@Override
public void updateList(List<DistributionParcelListEntity> updateParcelList) {
distributionParcelListService.updateBatchById(updateParcelList);
//把updateParcelList通过warehouseId分组
Map<Long, List<DistributionParcelListEntity>> map = updateParcelList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getWarehouseId));
map.keySet().forEach(warehouseId -> {
List<DistributionParcelListEntity> parcelListEntityList = map.get(warehouseId);
if(!Objects.isNull(parcelListEntityList)){
//把parcelListEntityList中的orderCode放入一个set
Set<String> orderCodeSet = parcelListEntityList.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet());
orderCodeSet.forEach(orderCode -> {
distributionStockArticleService.updateOrderInfo(orderCode,warehouseId);
});
}
});
}
}

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java

@ -4160,7 +4160,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
stockupEntity.setIsDeleted(0);
stockupEntity.setStatus(1);
stockupEntity.setCreateUser(user.getUserId());
stockupEntity.setCreateDept(Long.parseLong(user.getDeptId()));
stockupEntity.setCreateDept(myCurrentWarehouse.getDepartment());
stockupEntity.setCreateTime(new Date());
// stockupEntity.setOutboundDate(new Date());
stockupEntity.setWarehouseId(myCurrentWarehouse.getId());

63
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/ExecutorConfig.java

@ -0,0 +1,63 @@
package com.logpm.trunkline.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Nonnull;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
@Slf4j
@EnableAsync
public class ExecutorConfig {
@Bean
public Executor asyncExecutor() {
log.info("start async executor");
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
// 配置核心线程数
threadPoolTaskExecutor.setCorePoolSize(10);
// 配置最大线程数
threadPoolTaskExecutor.setMaxPoolSize(20);
// 配置队列大小
// threadPoolTaskExecutor.setQueueCapacity(ThreadPoolConstant.QUEUE_CAPACITY);
// 配置线程池中线程的名称前缀
threadPoolTaskExecutor.setThreadNamePrefix("IMPORT_ADVANCE_DATA");
// HelloWorldServiceImpl rejection-policy: 当pool已经达到max size时,如何处理新任务:
// CallerRunsPolicy: 不在新线程中执行任务,而是由调用者所在的线程来执行;
// AbortPolicy: 拒绝执行新任务,并抛出RejectedExecutionException异常;
// DiscardPolicy:丢弃当前将要加入队列的任务;
// DiscardOldestPolicy:丢弃任务队列中最旧的任务;
threadPoolTaskExecutor.setRejectedExecutionHandler(
new ThreadPoolExecutor.CallerRunsPolicy()
);
threadPoolTaskExecutor.setTaskDecorator(new ContextCopyingDecorator());
threadPoolTaskExecutor.initialize();
return threadPoolTaskExecutor;
}
static class ContextCopyingDecorator implements TaskDecorator {
@Nonnull
@Override
public Runnable decorate(@Nonnull Runnable runnable) {
RequestAttributes context = RequestContextHolder.currentRequestAttributes();
return () -> {
try {
RequestContextHolder.setRequestAttributes(context);
runnable.run();
} finally {
RequestContextHolder.resetRequestAttributes();
}
};
}
}
}

1
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java

@ -1839,6 +1839,7 @@ public class CarsLoadController {
return R.fail(400,"仓库信息为空");
}
loadCarsDTO.setWarehouseId(myCurrentWarehouse.getId());
loadCarsDTO.setWarehouseName(myCurrentWarehouse.getName());
if(Objects.isNull(loadScanIds) || loadScanIds.size() < 1){
log.warn(method+"批量签收ids为空 loadScanIds={}",loadScanIds);

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

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.trunkline.dto.AdvanceDTO;
import com.logpm.trunkline.dto.InComingDTO;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.vo.CustomerInfoVO;
import com.logpm.trunkline.vo.OpenOrderVO;
@ -12,6 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
@Mapper
public interface TrunklineAdvanceMapper extends BaseMapper<TrunklineAdvanceEntity> {
@ -37,4 +39,6 @@ public interface TrunklineAdvanceMapper extends BaseMapper<TrunklineAdvanceEntit
List<TrunklineAdvanceVO> findIncomingOrderList(@Param("param") InComingDTO inComingDTO);
Integer findAllNumByOrderCode(@Param("orderCode") String orderCode);
List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(@Param("orderCodeSet") Set<String> orderCodeSet);
}

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

@ -165,4 +165,22 @@
and is_deleted = 0
</select>
<select id="findListByExistsAndOrderCodeSet" resultType="com.logpm.trunkline.entity.TrunklineAdvanceEntity">
select *
from logpm_trunkline_advance lta
where exists(
select 1 from (
<foreach collection="orderCodeSet" index="ind" item="item">
<if test="ind == 0">
select #{item} orderCode
</if>
<if test="ind != 0">
union all
select #{item} orderCode
</if>
</foreach>
) orderCodes where orderCodes.orderCode = lta.order_code)
</select>
</mapper>

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

@ -145,4 +145,6 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper<TrunklineCarsLoa
List<TrunklineCarsLoadScanEntity> findListByIdsNoPackage(@Param("carsLoadScanIds") List<Long> carsLoadScanIds,@Param("warehouseId") Long warehouseId);
List<String> findIncomingOrdeCodesByCarsLoadScanIds(@Param("carsLoadScanIds") List<Long> carsLoadScanIds, @Param("warehouseId") Long warehouseId);
List<TrunklineCarsLoadScanVO> findListHasSignOrderIdByIds(@Param("carsLoadScanIds") List<Long> loadScanIds);
}

12
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml

@ -702,4 +702,16 @@
group by ldsa.order_code,ldsa.id
</select>
<select id="findListHasSignOrderIdByIds" resultType="com.logpm.trunkline.vo.TrunklineCarsLoadScanVO">
select ltcls.*,
ltco.sign_order_id signOrderId
from logpm_trunkline_cars_load_scan ltcls
left join logpm_trunkline_cars_order ltco on ltco.waybill_id = ltcls.waybill_id and ltco.order_code = ltcls.order_code and ltcls.node_id = ltco.warehouse_id
where ltcls.scan_status = '1'
and ltcls.id in
<foreach collection="carsLoadScanIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

14
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IAsyncService.java

@ -0,0 +1,14 @@
package com.logpm.trunkline.service;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import org.springframework.scheduling.annotation.Async;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public interface IAsyncService {
@Async("asyncExecutor")
CompletableFuture<Boolean> getResponseFromCp(List<TrunklineAdvanceDetailEntity> list, int queryType);
}

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

@ -11,6 +11,7 @@ import com.logpm.trunkline.vo.TrunklineAdvanceVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Set;
public interface ITrunklineAdvanceService extends BaseService<TrunklineAdvanceEntity> {
@ -38,4 +39,5 @@ public interface ITrunklineAdvanceService extends BaseService<TrunklineAdvanceEn
List<String> incomingPackageBatch(Long advanceId, Long warehouseId, List<TrunklineAdvanceDetailEntity> detailList, Long userId, Long deptId, String tenantId);
List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(Set<String> orderCodeSet);
}

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

@ -140,4 +140,6 @@ public interface ITrunklineCarsLoadScanService extends BaseService<TrunklineCars
List<TrunklineCarsLoadScanEntity> findListByIdsNoPackage(List<Long> carsLoadScanIds, Long warehouseId);
List<String> findIncomingOrdeCodesByCarsLoadScanIds(List<Long> carsLoadScanIds, Long warehouseId);
List<TrunklineCarsLoadScanVO> findListHasSignOrderIdByIds(List<Long> loadScanIds);
}

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

@ -4,8 +4,12 @@ import com.logpm.trunkline.entity.TrunklineCarsLoadScanEntity;
import com.logpm.trunkline.entity.TrunklineCarsSignLogEntity;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface ITrunklineCarsSignLogService extends BaseService<TrunklineCarsSignLogEntity> {
void addEntity(TrunklineCarsLoadScanEntity carsLoadScanEntity,String remark);
void saveSignLog(Long warehouseId,String warehouseName,Long loadId,String loadCode,Long waybillId,String waybillNo,String orderCode,String scanCode,Integer num,Integer type,Integer isData,Integer isAbnormal,Long trayId,String trayCode,String trayName,Long fromWarehouseId,Long loadScanId,String remark);
void addList(List<TrunklineCarsLoadScanEntity> updateCarsLoadScanList, String remark);
}

26
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java

@ -0,0 +1,26 @@
package com.logpm.trunkline.service.impl;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.service.IAsyncService;
import com.logpm.trunkline.service.ITrunklineAdvanceDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Service
public class AsyncServiceImpl implements IAsyncService {
@Autowired
private ITrunklineAdvanceDetailService advanceDetailService;
@Override
public CompletableFuture<Boolean> getResponseFromCp(List<TrunklineAdvanceDetailEntity> list, int queryType) {
return CompletableFuture
.completedFuture(
advanceDetailService.saveBatch(list)
);
}
}

220
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java

@ -52,6 +52,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Slf4j
@ -89,6 +90,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
private final IBasicdataOpenIncomingClient basicdataOpenIncomingClient;
private final ITrunklineCarsLoadService carsLoadService;
private final IBasicdataStoreContactClient basicdataStoreContactClient;
private final IAsyncService asyncService;
@Override
public IPage<TrunklineAdvanceVO> advancePageList(AdvanceDTO advanceDTO) {
@ -1027,27 +1029,50 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
listMap.remove("null&null");
//把pacakgeDetailExcelDTOS中的orderCode存入一个set集合
Set<String> orderCodeSet = pacakgeDetailExcelDTOS.parallelStream().map(PacakgeDetailExcelDTO::getOrderCode).collect(Collectors.toSet());
Set<String> set = listMap.keySet();
List<TrunklineAdvanceDetailEntity> advanceDetailEntities = new ArrayList<>();
List<TrunklineAdvanceEntity> advanceEntityList = new ArrayList<>();
for (String str : set) {
List<PacakgeDetailExcelDTO> detailExcelDTOS = listMap.get(str);
PacakgeDetailExcelDTO pacakgeDetailExcelDTO = detailExcelDTOS.get(0);
Map<String,TrunklineAdvanceEntity> advanceEntityMap = new HashMap<>();
List<Long> advanceIds = new ArrayList<>();
List<TrunklineAdvanceEntity> detailEntities = advanceService.findListByExistsAndOrderCodeSet(orderCodeSet);
//把detailEntities转化成以orderCode和trainNumber为key的map
detailEntities.forEach(advanceEntity -> {
String orderCode = advanceEntity.getOrderCode();
String trainNumber = advanceEntity.getTrainNumber();
String key = orderCode + "&" + trainNumber;
advanceEntityMap.put(key,advanceEntity);
});
Map<String, List<TrunklineAdvanceEntity>> advanceMap = detailEntities.parallelStream().collect(Collectors.groupingBy(a -> a.getOrderCode() + "&" + a.getTrainNumber()));
listMap.keySet().forEach(str -> {
String[] split = str.split("&");
String orderCode = split[0];
String trainNumber = split[1];
List<String> orderPackageCodes = new ArrayList<>();
TrunklineAdvanceEntity advanceEntity = advanceService.findEntityByOrderCodeAndTrainNumber(orderCode, trainNumber);
if("null".equals(trainNumber)){
trainNumber = null;
}
List<PacakgeDetailExcelDTO> excelDTOS = listMap.get(str);
PacakgeDetailExcelDTO pacakgeDetailExcelDTO = excelDTOS.get(0);
TrunklineAdvanceEntity advanceEntity = advanceEntityMap.get(str);
if (Objects.isNull(advanceEntity)) {
advanceEntity = new TrunklineAdvanceEntity();
advanceEntity.setWarehouseId(warehouseId);
advanceEntity.setWarehouseName(warehouseName);
advanceEntity.setOrderCode(orderCode);
advanceEntity.setArea(pacakgeDetailExcelDTO.getArea());
advanceEntity.setOrderType("Label");
advanceEntity.setBrand(pacakgeDetailExcelDTO.getBrand());
advanceEntity.setTotalNum(detailExcelDTOS.size());
advanceEntity.setTotalNum(excelDTOS.size());
String firsts = pacakgeDetailExcelDTO.getFirsts();
advanceEntity.setPackName(firsts);
advanceEntity.setDealerCode(pacakgeDetailExcelDTO.getDealerCode());
@ -1076,81 +1101,132 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceEntity.setFreezeStatus("0");
advanceEntity.setLegacyStatus("0");
advanceEntity.setCreateUserName(AuthUtil.getNickName());
advanceService.save(advanceEntity);
advanceEntityList.add(advanceEntity);
} else {
Long advanceId = advanceEntity.getId();
orderPackageCodes = advanceDetailService.findOrderPackageCodesByAdvanceId(advanceId);
advanceIds.add(advanceEntity.getId());
advanceEntityMap.put(advanceEntity.getOrderCode()+"&"+advanceEntity.getTrainNumber(),advanceEntity);
}
});
for (PacakgeDetailExcelDTO detailExcelDTO : detailExcelDTOS) {
String orderPackageCode = detailExcelDTO.getOrderPackageCode();
if (orderPackageCodes.contains(orderPackageCode)) {
continue;
}
TrunklineAdvanceDetailEntity advanceDetailModel = new TrunklineAdvanceDetailEntity();
advanceDetailModel = new TrunklineAdvanceDetailEntity();
advanceDetailModel.setWarehouseId(warehouseId);
advanceDetailModel.setWarehouseName(warehouseName);
advanceDetailModel.setAdvanceId(advanceEntity.getId());
advanceDetailModel.setOrderCode(orderCode);
advanceDetailModel.setOrderPackageCode(orderPackageCode);
advanceDetailModel.setBrand(detailExcelDTO.getBrand());
advanceDetailModel.setSystemType("线上");
String firsts = detailExcelDTO.getFirsts();
advanceDetailModel.setFirstPackName(firsts);
String sencods = detailExcelDTO.getSencods();
if (StringUtil.isBlank(sencods)) {
advanceDetailModel.setSecondPackName(firsts);
} else {
advanceDetailModel.setSecondPackName(sencods);
}
String thirds = detailExcelDTO.getThirds();
if (StringUtil.isBlank(thirds)) {
advanceDetailModel.setThirdPackName(firsts);
} else {
advanceDetailModel.setThirdPackName(thirds);
}
advanceDetailModel.setQuantity(1);
advanceDetailModel.setServiceNum(detailExcelDTO.getServiceNum());
advanceDetailModel.setPackageStatus("0");
if (!Objects.isNull(detailExcelDTO.getVolume())) {
advanceDetailModel.setVolume(new BigDecimal(detailExcelDTO.getVolume()));
}
advanceService.saveBatch(advanceEntityList);
String materialName = detailExcelDTO.getMaterialName();
String materialCode = detailExcelDTO.getMaterialCode();
advanceEntityList.forEach(advanceEntity -> {
advanceIds.add(advanceEntity.getId());
advanceEntityMap.put(advanceEntity.getOrderCode()+"&"+advanceEntity.getTrainNumber(),advanceEntity);
});
if (StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialName)) {
BasicMaterialEntity basicMaterialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName);
if (Objects.isNull(basicMaterialEntity)) {
basicMaterialEntity = new BasicMaterialEntity();
basicMaterialEntity.setProductCode(materialCode);
basicMaterialEntity.setName(materialName);
basicMaterialEntity.setBrandId("1713382405517201409");
basicMaterialEntity.setProperty("家配");
basicMaterialEntity.setSpecification("件");
basicMaterialEntity.setPackingSpecification("1件/箱");
basicMaterialEntity.setLogpmUnit("箱");
basicMaterialEntity.setSku(materialCode);
basicMaterialEntity.setPackageNum("1");
basicMaterialEntity.setHide(1);
Long aLong = basicMaterialClient.addMaterial(basicMaterialEntity);
basicMaterialEntity.setId(aLong);
//通过advanceIds查询所有advanceDetail
QueryWrapper<TrunklineAdvanceDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.in("advance_id",advanceIds)
.eq("is_deleted",0);
List<TrunklineAdvanceDetailEntity> advanceDetailEntityList = advanceDetailService.list(queryWrapper);
//把advanceDetailEntityList通过advanceId分组并且把集合转化为orderPackageCode的集合
Map<Long, List<String>> map = advanceDetailEntityList.parallelStream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getAdvanceId, Collectors.mapping(TrunklineAdvanceDetailEntity::getOrderPackageCode, Collectors.toList())));
Map<String,Long> materialMap = new HashMap<>();
listMap.keySet().forEach(str -> {
List<PacakgeDetailExcelDTO> pacakgeDetailExcelList = listMap.get(str);
String[] split = str.split("&");
String orderCode = split[0];
TrunklineAdvanceEntity advanceEntity = advanceEntityMap.get(str);
if(!Objects.isNull(advanceEntity)){
Long advanceId = advanceEntity.getId();
List<String> orderPackageCodes = map.get(advanceId);
pacakgeDetailExcelList.forEach(pacakgeDetailExcelDTO -> {
String orderPackageCode = pacakgeDetailExcelDTO.getOrderPackageCode();
if(Objects.isNull(orderPackageCodes) || !orderPackageCodes.contains(orderPackageCode)){
TrunklineAdvanceDetailEntity advanceDetailModel = new TrunklineAdvanceDetailEntity();
advanceDetailModel.setWarehouseId(warehouseId);
advanceDetailModel.setWarehouseName(warehouseName);
advanceDetailModel.setAdvanceId(advanceId);
advanceDetailModel.setOrderCode(orderCode);
advanceDetailModel.setOrderPackageCode(orderPackageCode);
advanceDetailModel.setBrand(pacakgeDetailExcelDTO.getBrand());
advanceDetailModel.setSystemType("线上");
String firsts = pacakgeDetailExcelDTO.getFirsts();
advanceDetailModel.setFirstPackName(firsts);
String sencods = pacakgeDetailExcelDTO.getSencods();
if (StringUtil.isBlank(sencods)) {
advanceDetailModel.setSecondPackName(firsts);
} else {
advanceDetailModel.setSecondPackName(sencods);
}
String thirds = pacakgeDetailExcelDTO.getThirds();
if (StringUtil.isBlank(thirds)) {
advanceDetailModel.setThirdPackName(firsts);
} else {
advanceDetailModel.setThirdPackName(thirds);
}
advanceDetailModel.setQuantity(1);
advanceDetailModel.setServiceNum(pacakgeDetailExcelDTO.getServiceNum());
advanceDetailModel.setPackageStatus("0");
if (!Objects.isNull(pacakgeDetailExcelDTO.getVolume())) {
advanceDetailModel.setVolume(new BigDecimal(pacakgeDetailExcelDTO.getVolume()));
}
String materialName = pacakgeDetailExcelDTO.getMaterialName();
String materialCode = pacakgeDetailExcelDTO.getMaterialCode();
if (StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialName)) {
Long materialId = materialMap.get(materialCode);
if(!Objects.isNull(materialId)){
advanceDetailModel.setMaterialId(materialId);
advanceDetailModel.setMaterialCode(materialCode);
advanceDetailModel.setMaterialName(materialName);
}else{
BasicMaterialEntity basicMaterialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName);
if (Objects.isNull(basicMaterialEntity)) {
basicMaterialEntity = new BasicMaterialEntity();
basicMaterialEntity.setProductCode(materialCode);
basicMaterialEntity.setName(materialName);
BasicdataBrandEntity basicdataBrandEntity = basicdataBrandClient.findEntityByName(pacakgeDetailExcelDTO.getBrand());
if(Objects.isNull(basicdataBrandEntity)){
basicMaterialEntity.setBrandId("1713382405517201409");
}else{
basicMaterialEntity.setBrandId(basicdataBrandEntity.getId()+"");
}
basicMaterialEntity.setProperty("家配");
basicMaterialEntity.setSpecification("件");
basicMaterialEntity.setPackingSpecification("1件/箱");
basicMaterialEntity.setLogpmUnit("箱");
basicMaterialEntity.setSku(materialCode);
basicMaterialEntity.setPackageNum("1");
basicMaterialEntity.setHide(1);
Long aLong = basicMaterialClient.addMaterial(basicMaterialEntity);
basicMaterialEntity.setId(aLong);
materialMap.put(materialCode,aLong);
advanceDetailModel.setMaterialId(aLong);
advanceDetailModel.setMaterialCode(materialCode);
advanceDetailModel.setMaterialName(materialName);
}else{
materialMap.put(materialCode,basicMaterialEntity.getId());
advanceDetailModel.setMaterialId(basicMaterialEntity.getId());
advanceDetailModel.setMaterialCode(basicMaterialEntity.getProductCode());
advanceDetailModel.setMaterialName(basicMaterialEntity.getName());
}
}
}
advanceDetailEntities.add(advanceDetailModel);
}
advanceDetailModel.setMaterialId(basicMaterialEntity.getId());
advanceDetailModel.setMaterialCode(basicMaterialEntity.getProductCode());
advanceDetailModel.setMaterialName(basicMaterialEntity.getName());
}
advanceDetailEntities.add(advanceDetailModel);
});
}
});
if (!advanceDetailEntities.isEmpty()) {
//把advanceDetailEntities分成相等数量的10个集合
List<List<TrunklineAdvanceDetailEntity>> advanceDetailEntitiesList = advanceDetailEntities.stream().collect(Collectors.groupingBy(item -> advanceDetailEntities.indexOf(item) / 1000)).entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList());
List<CompletableFuture> comlist = new ArrayList<>();
for (int i = 0; i < advanceDetailEntitiesList.size(); i++) {
List<TrunklineAdvanceDetailEntity> list = advanceDetailEntitiesList.get(i);
CompletableFuture<Boolean> fromCpFirstReq = asyncService.getResponseFromCp(list, i+1);
comlist.add(fromCpFirstReq);
}
CompletableFuture.allOf(comlist.toArray(new CompletableFuture[0])).join();
// int all = orderPackageCodes.size() + advanceDetailEntities.size();
// if(all != advanceEntity.getTotalNum()){
// advanceService.updateTotalNumById(advanceEntity.getId(),all);
// }
}
advanceDetailService.saveBatch(advanceDetailEntities);
return R.data(advanceEntityList);
}

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

@ -625,4 +625,9 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
return orderPackageCodes;
}
@Override
public List<TrunklineAdvanceEntity> findListByExistsAndOrderCodeSet(Set<String> orderCodeSet) {
return baseMapper.findListByExistsAndOrderCodeSet(orderCodeSet);
}
}

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

@ -341,4 +341,9 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl<TrunklineC
return baseMapper.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId);
}
@Override
public List<TrunklineCarsLoadScanVO> findListHasSignOrderIdByIds(List<Long> loadScanIds) {
return baseMapper.findListHasSignOrderIdByIds(loadScanIds);
}
}

194
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -913,6 +913,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
String loadStatus = carsLoadEntity.getLoadStatus();
if (!"80".equals(loadStatus)) {
log.warn("#############unloadByLoadId: 配载计划已终点卸车确认 loadStatus={}", loadStatus);
throw new CustomerException(400, "配载计划已终点卸车确认");
}
if (!"20".equals(loadStatus) && !"40".equals(loadStatus)) {
log.warn("#############unloadByLoadId: 配载计划暂未到车 loadStatus={}", loadStatus);
throw new CustomerException(400, "配载计划暂未到车");
@ -3409,6 +3414,17 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R.fail(405, "配载计划信息不存在");
}
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId);
if (Objects.isNull(loadLineEntity)) {
log.warn("############batchUnload: 配载计划节点信息不存在 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "配载计划节点信息不存在");
}
String unloadStatus = loadLineEntity.getUnloadStatus();
if(!"0".equals(unloadStatus)){
log.warn("############batchUnload: 当前网点已经卸车确认 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "当前网点已经卸车确认");
}
Long nowWarehouseId = carsLoadEntity.getNowWarehouseId();
if (!warehouseId.equals(nowWarehouseId)) {
log.warn("############batchUnload: 当前节点还未到车 loadId={} warehouseId={}", loadId, warehouseId);
@ -3452,6 +3468,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
// //把waybillEntities转成WaybillNo为键值的map
// Map<String,WarehouseWaybillEntity> waybillMap = waybillEntities.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, e -> e));
List<TrunklineCarsUnloadLogEntity> unloadLogList = new ArrayList<>();
List<String> orderCodeList = trunklineCarsLoadScanService.findIncomingOrdeCodesByCarsLoadScanIds(carsLoadScanIds,warehouseId);
Map<String,Long> orderCodes = new HashMap<>();
if(!Objects.isNull(orderCodeList)){
@ -3467,13 +3485,45 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//把loadScanEntityList通过isData=0和isData=1分成两个新的list
List<TrunklineCarsLoadScanEntity> loadScanEntityListNoData = loadScanEntityList.stream().filter(e -> e.getIsData() == 0).collect(Collectors.toList());
loadScanEntityListNoData.forEach(e -> {
Integer isAbnormal = 0;
String remark = "正常卸车";
e.setScanStatus("2");
e.setUnloadNodeId(warehouseId);
e.setUnloadNodeName(warehouseName);
e.setUnloadAbnormal(0);
Long finalNodeId = e.getFinalNodeId();
if(!finalNodeId.equals(warehouseId)){
isAbnormal = 1;
remark = "卸车仓库与目的仓不一致,异常卸车";
}
e.setUnloadAbnormal(isAbnormal);
e.setUnloadNum(1);
e.setUnloadUserName(nickName);
e.setRemark(remark);
updateScanEntityList.add(e);
TrunklineCarsUnloadLogEntity entity = new TrunklineCarsUnloadLogEntity();
entity.setTenantId(tenantId);
entity.setCreateUser(userId);
entity.setUpdateUser(userId);
entity.setCreateDept(deptId);
entity.setCreateTime(date);
entity.setUpdateTime(date);
entity.setWarehouseId(warehouseId);
entity.setWarehouseName(warehouseName);
entity.setLoadId(loadId);
entity.setLoadCode(carsLoadEntity.getCarsNo());
entity.setWaybillId(e.getWaybillId());
entity.setWaybillNo(e.getWaybillNo());
entity.setOrderCode(e.getOrderCode());
entity.setScanCode(e.getScanCode());
entity.setNum(e.getUnloadNum());
entity.setType(e.getType());
entity.setIsData(e.getIsData());
entity.setIsAbnormal(isAbnormal);
entity.setFromWarehouseId(e.getFromWarehouseId());
entity.setLoadScanId(e.getId());
entity.setRemark(remark);
unloadLogList.add(entity);
});
@ -3484,8 +3534,6 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//需要修改仓库信息的打托数据
List<String> trayCodes = new ArrayList<>();
List<String> orderPackageCodes = new ArrayList<>();
List<TrunklineCarsUnloadLogEntity> unloadLogList = new ArrayList<>();
List<TrunklineCarsLoadScanEntity> loadScanEntityListHasData = loadScanEntityList.stream().filter(e -> e.getIsData() == 1).collect(Collectors.toList());
@ -4174,44 +4222,96 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
@Override
public R batchSign(LoadCarsDTO loadCarsDTO) {
List<Long> loadScanIds = loadCarsDTO.getLoadScanIds();
Long warehouseId = loadCarsDTO.getWarehouseId();
String warehouseName = loadCarsDTO.getWarehouseName();
List<TrunklineCarsLoadScanEntity> list = trunklineCarsLoadScanService.findListByIds(loadScanIds);
List<TrunklineCarsLoadScanVO> list = trunklineCarsLoadScanService.findListHasSignOrderIdByIds(loadScanIds);
List<DistributionParcelListEntity> parcelListEntityList = trunklineCarsLoadScanService.findParceListByCarsLoadScanIds(loadScanIds);
//把parcelListEntityList通过orderPackageCode分组
Map<String, List<DistributionParcelListEntity>> parcelListMap = parcelListEntityList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getOrderPackageCode));
for (TrunklineCarsLoadScanEntity carsLoadScanEntity : list) {
Long loadScanId = carsLoadScanEntity.getId();
Long loadId = carsLoadScanEntity.getLoadId();
Long warehouseId = carsLoadScanEntity.getWarehouseId();
String orderCode = carsLoadScanEntity.getOrderCode();
String waybillNo = carsLoadScanEntity.getWaybillNo();
String scanCode = carsLoadScanEntity.getScanCode();
Integer num = carsLoadScanEntity.getNum();
QueryWrapper<TrunklineCarsOrderEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("load_id", loadId)
.eq("node_id", warehouseId)
.eq("order_code", orderCode)
.eq("waybill_no", waybillNo);
TrunklineCarsOrderEntity one = trunklineCarsOrderService.getOne(queryWrapper);
if (Objects.isNull(one)) {
log.warn("############batchSign: 包件不在该车次中 ");
return R.fail(405, "包件不在该车次中");
}
List<Long> signOrderIds = new ArrayList<>();
List<TrunklineCarsLoadScanEntity> updateCarsLoadScanList = new ArrayList<>();
List<DistributionParcelListEntity> updateParcelList = new ArrayList<>();
String isCustomer = one.getIsCustomer();
if ("0".equals(isCustomer)) {
log.warn("############batchSign: 订单不是直发商家订单 orderCode={} waybillNo={}", orderCode, waybillNo);
return R.fail(405, "订单不是直发商家订单");
}
Date date = new Date();
Long signOrderId = one.getSignOrderId();
if(!list.isEmpty()){
//排除list中scanStatus = 1的数据
list = list.stream().filter(e -> !"1".equals(e.getScanStatus())).collect(Collectors.toList());
Integer type = carsLoadScanEntity.getType();
if (1 == type) {
signScanPackageCode(signOrderId, scanCode, "PC批量签收");
} else if (2 == type) {
signZeroOrder(signOrderId, loadScanId, num, "PC批量签收");
List<String> orderPackageCodes = new ArrayList<>();
Set<Long> loadIds = new HashSet<>();
//把list通过signOrderId进行分组
Map<Long, List<TrunklineCarsLoadScanVO>> map = list.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanVO::getSignOrderId));
map.keySet().forEach(e -> {
List<TrunklineCarsLoadScanVO> trunklineCarsLoadScanVOS = map.get(e);//该签收单对应的包件
trunklineCarsLoadScanVOS.forEach(t ->{
TrunklineCarsLoadScanEntity entity = new TrunklineCarsLoadScanEntity();
BeanUtil.copy(t,entity);
entity.setScanStatus("3");
entity.setUnloadNum(t.getNum());
entity.setSignTime(date);
if(entity.getType().equals(1)){
String scanCode = entity.getScanCode();
List<DistributionParcelListEntity> parcelList = parcelListMap.get(scanCode);
if(!Objects.isNull(parcelList)){
parcelList.forEach(p ->{
p.setOrderPackageStatus("70");
updateParcelList.add(p);
});
}
orderPackageCodes.add(entity.getScanCode());
}
updateCarsLoadScanList.add(entity);
loadIds.add(entity.getLoadId());
});
signOrderIds.add(e);
});
trunklineCarsLoadScanService.updateBatchById(updateCarsLoadScanList);
//生成签收记录
trunklineCarsSignLogService.addList(updateCarsLoadScanList, "PC批量签收");
//重新计算数量
loadIds.forEach(this::updateNumByLoadId);
//重新计算签收单的数量
signOrderIds.forEach(this::updateSignOrderNumBySignOrderId);
distributionParcelListClient.updateList(updateParcelList);
try {
String content = "包件在 " + warehouseName + "直发商家签收";
packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseName, WorkNodeEnums.SIGN_DIRECT_SHIPPER.getCode(), content);
} catch (Exception e) {
log.warn("###########存入日志信息失败");
}
}
// 推送签收数据给工厂
try {
updateParcelList.forEach(parcelListEntity -> {
if (ObjectUtil.isNotEmpty(parcelListEntity)) {
List<Object> contents = new ArrayList<>();
JSONObject jsonObject = new JSONObject();
jsonObject.put("packageCode", parcelListEntity.getOrderPackageCode());
contents.add(jsonObject);
NodePushMsg msg = new NodePushMsg();
msg.setNode(WorkNodeEnums.CLERK_REVIEW);
msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName()));
msg.setOperator(AuthUtil.getNickName());
msg.setOperatorTime(new Date());
msg.setContent(contents);
log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg));
factoryDataMessageSender.sendNodeDataByBrand(msg);
}
});
} catch (Exception e) {
log.error("推送签收数据给工厂失败 {}", e);
}
}
return R.success("签收完成");
}
@ -5262,10 +5362,15 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R.fail(405, "配载计划信息不存在");
}
String loadCode = carsLoadEntity.getCarsNo();
String loadStatus = carsLoadEntity.getLoadStatus();
if("80".equals(loadStatus)){
log.warn("##############unloadPackage: 配载计划已经卸车确认 loadId={}", loadId);
return R.fail(405, "配载计划已经卸车确认");
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId);
if (Objects.isNull(loadLineEntity)) {
log.warn("############unloadPackage: 配载计划节点信息不存在 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "配载计划节点信息不存在");
}
String unloadStatus = loadLineEntity.getUnloadStatus();
if(!"0".equals(unloadStatus)){
log.warn("############unloadPackage: 当前网点已经卸车确认 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "当前网点已经卸车确认");
}
TrunklineCarsLoadLineEntity carsLoadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId);
@ -5671,10 +5776,15 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
String loadCode = carsLoadEntity.getCarsNo();
String loadStatus = carsLoadEntity.getLoadStatus();
if("80".equals(loadStatus)){
log.warn("##############unloadZero: 配载计划已经卸车确认 loadStatus={}", loadStatus);
return R.fail(405, "配载计划已经卸车确认");
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService.findEntityByLoadIdAndNodeId(loadId, warehouseId);
if (Objects.isNull(loadLineEntity)) {
log.warn("############unloadZero: 配载计划节点信息不存在 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "配载计划节点信息不存在");
}
String unloadStatus = loadLineEntity.getUnloadStatus();
if(!"0".equals(unloadStatus)){
log.warn("############unloadZero: 当前网点已经卸车确认 loadId={} warehouseId={}", loadId, warehouseId);
return R.fail(405, "当前网点已经卸车确认");
}
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);

33
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsSignLogServiceImpl.java

@ -9,6 +9,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
@AllArgsConstructor
@ -60,4 +63,34 @@ public class TrunklineCarsSignLogServiceImpl extends BaseServiceImpl<TrunklineCa
trunklineCarsSignLogEntity.setRemark(remark);
save(trunklineCarsSignLogEntity);
}
@Override
public void addList(List<TrunklineCarsLoadScanEntity> updateCarsLoadScanList, String remark) {
List<TrunklineCarsSignLogEntity> signLogList = new ArrayList<>();
updateCarsLoadScanList.forEach(carsLoadScanEntity -> {
TrunklineCarsSignLogEntity trunklineCarsSignLogEntity = new TrunklineCarsSignLogEntity();
trunklineCarsSignLogEntity.setLoadId(carsLoadScanEntity.getLoadId());
trunklineCarsSignLogEntity.setLoadCode(carsLoadScanEntity.getLoadCode());
trunklineCarsSignLogEntity.setLoadScanId(carsLoadScanEntity.getId());
trunklineCarsSignLogEntity.setWarehouseId(carsLoadScanEntity.getWarehouseId());
trunklineCarsSignLogEntity.setWarehouseName(carsLoadScanEntity.getWarehouseName());
trunklineCarsSignLogEntity.setWaybillId(carsLoadScanEntity.getWaybillId());
trunklineCarsSignLogEntity.setWaybillNo(carsLoadScanEntity.getWaybillNo());
trunklineCarsSignLogEntity.setOrderCode(carsLoadScanEntity.getOrderCode());
trunklineCarsSignLogEntity.setScanCode(carsLoadScanEntity.getScanCode());
trunklineCarsSignLogEntity.setNum(carsLoadScanEntity.getNum());
trunklineCarsSignLogEntity.setType(carsLoadScanEntity.getType());
trunklineCarsSignLogEntity.setIsData(carsLoadScanEntity.getIsData());
trunklineCarsSignLogEntity.setIsAbnormal(carsLoadScanEntity.getSignAbnormal());
trunklineCarsSignLogEntity.setTrayId(carsLoadScanEntity.getTrayId());
trunklineCarsSignLogEntity.setTrayCode(carsLoadScanEntity.getTrayCode());
trunklineCarsSignLogEntity.setTrayName(carsLoadScanEntity.getTrayName());
trunklineCarsSignLogEntity.setFromWarehouseId(carsLoadScanEntity.getFromWarehouseId());
trunklineCarsSignLogEntity.setRemark(remark);
signLogList.add(trunklineCarsSignLogEntity);
});
saveBatch(signLogList);
}
}

Loading…
Cancel
Save