Browse Source

Merge remote-tracking branch 'origin/pre-production'

master
zhenghaoyu 3 days ago
parent
commit
c35bbcfa6c
  1. 4
      blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java
  2. 8
      blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java
  3. 1
      blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java
  4. 3
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java
  5. 44
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java
  6. 3
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java
  7. 172
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java
  8. 5
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderAllTaskVO.java
  9. 14
      blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile
  10. 96
      blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml
  11. 20
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java
  12. 50
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java
  13. 82
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java
  14. 48
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java
  15. 161
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java
  16. 85
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java
  17. 40
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java
  18. 39
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java
  19. 17
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java
  20. 74
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java
  21. 64
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java
  22. 88
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java
  23. 63
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java
  24. 72
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java
  25. 64
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java
  26. 180
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java
  27. 60
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java
  28. 16
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java
  29. 5
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml
  30. 16
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java
  31. 5
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml
  32. 16
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java
  33. 5
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml
  34. 21
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java
  35. 17
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml
  36. 52
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java
  37. 20
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java
  38. 78
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java
  39. 14
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java
  40. 14
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java
  41. 14
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java
  42. 14
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java
  43. 19
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java
  44. 13
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java
  45. 181
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java
  46. 22
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java
  47. 22
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java
  48. 22
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java
  49. 137
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java
  50. 139
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java
  51. 30
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java
  52. 27
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java
  53. 25
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java
  54. 21
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java
  55. 25
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java
  56. 26
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java
  57. 32
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java
  58. 38
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java
  59. 75
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java
  60. 73
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml
  61. 47
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml
  62. 73
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml
  63. 31
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml
  64. 40
      blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml
  65. 49
      blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java
  66. 1
      blade-service/logpm-factory-data/pom.xml
  67. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java
  68. 1
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml
  69. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java
  70. 1
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml
  71. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java
  72. 19
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java
  73. 43
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java
  74. 29
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java
  75. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java
  76. 30
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

4
blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java

@ -106,6 +106,10 @@ public interface ModuleNameConstant {
* 索菲亚工厂数据模块
*/
String LOGPM_FACTORY_DATA_SUOFEIYA_NAME = "logpm-factory-data-suofeiya" + DEVAUTH;
/**
* 百得胜工厂数据模块
*/
String LOGPM_FACTORY_DATA_PATERSON_NAME = "logpm-factory-data-paterson" + DEVAUTH;
/**
* 我乐工厂数据模块
*/

8
blade-biz-common/src/main/java/org/springblade/common/constant/factorydata/FactoryDataConstants.java

@ -95,6 +95,10 @@ public abstract class FactoryDataConstants {
String JP_NODE_DATA_PUSH = "factory.data.queue.jp.nodeDataPush" + DEVAUTH;
String JP_FACTORY_ORDER = "factory.data.queue.jp.factoryOrder" + DEVAUTH;
String JP_FACTORY_SHIPMENT = "factory.data.queue.jp.factoryShipment" + DEVAUTH;
/**
* 百得胜工厂订单
*/
String BDS_FACTORY_SHIPMENT = "factory.data.queue.bds.factoryShipment" + DEVAUTH;
/**
* 皮阿诺作业节点数据推送
*/
@ -149,6 +153,10 @@ public abstract class FactoryDataConstants {
String JP_NODE_DATA_PUSH = "jp.nodeDataPush" + DEVAUTH;
String JP_FACTORY_ORDER = "jp.factoryOrder" + DEVAUTH;
String JP_FACTORY_SHIPMENT = "jp.factoryShipment" + DEVAUTH;
/**
* 百得胜工厂订单
*/
String BDS_FACTORY_SHIPMENT = "bds.factoryShipment" + DEVAUTH;
/**
* 皮阿诺作业节点数据推送
*/

1
blade-service-api/logpm-factory-data-api/src/main/java/com/logpm/factorydata/enums/BrandEnums.java

@ -24,6 +24,7 @@ public enum BrandEnums implements Serializable {
OLO(8, "我乐"),
MHJ(9, "曼好家"),
LINSY(10, "林氏家居"),
BDS(11, "百得胜"),
;
private final Integer code;

3
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java

@ -7,6 +7,7 @@ import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity;
import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity;
import com.logpm.distribution.service.IDistributionSplitOrderTaskService;
import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO;
import com.logpm.distribution.vo.DistributionSplitOrderTaskVO;
import com.logpm.distribution.vo.SplitPackageOrderVO;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
@ -97,7 +98,7 @@ public class DistributionSplitOrderTaskController {
}
@GetMapping("/task-list")
public R<IPage<DistributionSplitOrderTaskEntity>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) {
public R<IPage<DistributionSplitOrderTaskVO>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) {
return distributionSplitOrderTaskService.taskList(query, distributionSplitTaskSearchDTO);
}

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

@ -81,30 +81,36 @@ public class DistributionStockArticleClient implements IDistributionStockArticle
String key = orderCode + warehouseId;
Boolean exists = bladeRedis.exists(key);
if(exists){
String idStr = bladeRedis.get(key);
if("1".equals(idStr)){
return 1L;
}else{
return Long.valueOf(idStr);
}
}else{
bladeRedis.setEx(key,"1",30L);
DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if(ObjectUtils.isNotEmpty(distributionStockArticle)){
bladeRedis.setEx(key,distributionStockArticle.getId(),30L);
return distributionStockArticle.getId();
try{
Boolean exists = bladeRedis.exists(key);
if(exists){
String idStr = bladeRedis.get(key);
if("1".equals(idStr)){
return 1L;
}else{
return Long.valueOf(idStr);
}
}else{
boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity);
if(saveFlag){
bladeRedis.setEx(key,distributionStockArticleEntity.getId(),30L);
return distributionStockArticleEntity.getId();
bladeRedis.setEx(key,"1",30L);
DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if(ObjectUtils.isNotEmpty(distributionStockArticle)){
bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L);
return distributionStockArticle.getId();
}else{
return 0L;
boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity);
if(saveFlag){
bladeRedis.setEx(key,distributionStockArticleEntity.getId().toString(),30L);
return distributionStockArticleEntity.getId();
}else{
return 0L;
}
}
}
}catch (Exception e){
log.error("#######addData: 保存订单失败",e);
return 0L;
}
}
@Override

3
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java

@ -7,6 +7,7 @@ import com.logpm.distribution.dto.splitOrder.DistributionSplitTaskSearchDTO;
import com.logpm.distribution.entity.DistributionSplitOrderAllTaskEntity;
import com.logpm.distribution.entity.DistributionSplitOrderTaskEntity;
import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO;
import com.logpm.distribution.vo.DistributionSplitOrderTaskVO;
import com.logpm.distribution.vo.SplitPackageOrderVO;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
@ -25,7 +26,7 @@ public interface IDistributionSplitOrderTaskService extends BaseService<Distribu
* @param distributionSplitTaskSearchDTO
* @return
*/
R<IPage<DistributionSplitOrderTaskEntity>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO);
R<IPage<DistributionSplitOrderTaskVO>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO);
/**
* 拆单总任务

172
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java

@ -24,6 +24,7 @@ import com.logpm.distribution.service.IDistributionSplitOrderLogService;
import com.logpm.distribution.service.IDistributionSplitOrderTaskService;
import com.logpm.distribution.service.IDistributionStockArticleService;
import com.logpm.distribution.vo.DistributionSplitOrderAllTaskVO;
import com.logpm.distribution.vo.DistributionSplitOrderTaskVO;
import com.logpm.distribution.vo.SplitPackageOrderVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -33,6 +34,7 @@ import org.springblade.common.constant.order.OrderSplitStateConstant;
import org.springblade.common.constant.order.OrderStatusConstant;
import org.springblade.common.constant.orderpackage.*;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -40,7 +42,9 @@ import org.springblade.core.redis.lock.LockType;
import org.springblade.core.redis.lock.RedisLockClient;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.system.cache.UserCache;
import org.springblade.system.entity.User;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.feign.IUserClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -65,7 +69,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
@Override
public R<IPage<DistributionSplitOrderTaskEntity>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) {
public R<IPage<DistributionSplitOrderTaskVO>> taskList(Query query, DistributionSplitTaskSearchDTO distributionSplitTaskSearchDTO) {
LambdaQueryWrapper<DistributionSplitOrderTaskEntity> queryWrapper = Wrappers.lambdaQuery();
if (distributionSplitTaskSearchDTO.getSplitOrderAllTaskId() != null) {
queryWrapper.eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, distributionSplitTaskSearchDTO.getSplitOrderAllTaskId());
@ -87,10 +91,31 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
}
IPage<DistributionSplitOrderTaskEntity> page = Condition.getPage(query);
List<DistributionSplitOrderTaskEntity> list = list(page, queryWrapper);
page.setRecords(list);
IPage<DistributionSplitOrderTaskVO> pageRes = Condition.getPage(query);
List<DistributionSplitOrderTaskEntity> list = list(page, queryWrapper);
List<DistributionSplitOrderTaskVO> listVo = new ArrayList<>();
if (list != null && !list.isEmpty()) {
Map<Long, String> userIdNameMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderTaskEntity::getCreateUser).collect(Collectors.toList()));
listVo = list.stream().map(item -> {
DistributionSplitOrderTaskVO distributionSplitOrderTaskVO = new DistributionSplitOrderTaskVO();
BeanUtil.copyProperties(item, distributionSplitOrderTaskVO);
distributionSplitOrderTaskVO.setCreateUserName(userIdNameMap.get(item.getCreateUser()));
return distributionSplitOrderTaskVO;
}).collect(Collectors.toList());
}
pageRes.setRecords(listVo);
pageRes.setPages(page.getPages());
pageRes.setTotal(page.getTotal());
return R.data(pageRes);
}
return R.data(page);
private Map<Long, String> getUserIdNameMap(List<Long> list) {
String createUserIds = list.stream().map((d) -> d + "").collect(Collectors.joining(","));
List<User> users = iUserClient.userInfoByIds(AuthUtil.getTenantId(), createUserIds).getData();
return users.stream().collect(Collectors.toMap(User::getId, User::getName));
}
@Transactional
@ -132,6 +157,15 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
return R.fail("订单"+ distributionStockArticle.getOrderCode() +"正在拆单中,不允许重复拆单");
}
int taskNumber = distributionSplitOrderTaskList
.stream()
.map(DistributionSplitOrderTaskEntity::getTaskNumber)
.mapToInt(Integer::intValue)
.sum();
if (packageAllowCount < taskNumber) {
return R.fail("拆单数大于订单包件数量,请重新填写,目前可拆单数量:" + packageAllowCount);
}
taskLock(stockArticleId, () -> {
String allTaskNo = getAllTaskNo();
DistributionSplitOrderAllTaskEntity allTask = new DistributionSplitOrderAllTaskEntity();
@ -141,10 +175,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
allTask.setNumber(distributionSplitOrderTaskList.size());
allTask.setState(OrderSplitStateConstant.InProgress.getValue());
allTask.setMallName(distributionStockArticle.getMallName());
int taskNumber = distributionSplitOrderTaskList.stream()
.map(DistributionSplitOrderTaskEntity::getTaskNumber)
.mapToInt(Integer::intValue)
.sum();
allTask.setOrderPackageNumber(taskNumber);
distributionSplitOrderAllTaskService.save(allTask);
@ -533,66 +564,25 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
if (task == null) {
return R.fail("任务不存在");
}
if (!task.getState().equals(OrderSplitStateConstant.InProgress.getValue())) {
return R.fail("拆单任务不在进行中,无法撤销");
}
DistributionSplitOrderAllTaskEntity allTask = distributionSplitOrderAllTaskService.getById(task.getSplitOrderAllTaskId());
if (allTask == null) {
return R.fail("总任务不存在");
}
DistributionStockArticleEntity oldStockArticle = distributionStockArticleService.getById(task.getStockArticleId());
DistributionStockArticleEntity newStockArticle = distributionStockArticleService.getById(task.getNewStockArticleId());
if (oldStockArticle == null) {
oldStockArticle = distributionStockArticleService.getOne(Wrappers.<DistributionStockArticleEntity>lambdaQuery()
.eq(DistributionStockArticleEntity::getId, task.getStockArticleId())
.eq(DistributionStockArticleEntity::getIsDeleted, 1)
);
if (oldStockArticle == null) {
return R.fail("订单错误,无法删除");
}
oldStockArticle.setIsDeleted(0);
}
List<DistributionParcelListEntity> packageList = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>lambdaQuery()
.eq(DistributionParcelListEntity::getStockArticleId, task.getNewStockArticleId()));
if (packageList.stream().anyMatch(distributionParcelListEntity -> OrderPackageReservationStatusConstant.yiyueyue.getValue().equals(distributionParcelListEntity.getOrderPackageReservationStatus()))) {
return R.fail("新的订单包件已预约,无法删除");
long count = count(
Wrappers.<DistributionSplitOrderTaskEntity>lambdaQuery()
.eq(DistributionSplitOrderTaskEntity::getSplitOrderAllTaskId, task.getSplitOrderAllTaskId())
.in(DistributionSplitOrderTaskEntity::getState, Arrays.asList(OrderSplitStateConstant.InProgress.getValue(), OrderSplitStateConstant.finish.getValue()))
);
if (count == 1) {
return R.fail("总任务下只有一条任务,无法撤销");
}
try {
distributionParcelListService.update(Wrappers.<DistributionParcelListEntity>lambdaUpdate()
.eq(DistributionParcelListEntity::getStockArticleId, task.getNewStockArticleId())
.set(DistributionParcelListEntity::getStockArticleId, task.getStockArticleId())
.set(DistributionParcelListEntity::getOrderCode, task.getOrderCode())
);
if (newStockArticle != null) {
newStockArticle.setTotalNumber(0);
newStockArticle.setHandQuantity(0);
distributionStockArticleService.updateById(newStockArticle);
oldStockArticle.setTotalNumber(oldStockArticle.getTotalNumber() + newStockArticle.getTotalNumber());
oldStockArticle.setHandQuantity(oldStockArticle.getHandQuantity() + newStockArticle.getHandQuantity());
}
distributionStockArticleService.updateById(oldStockArticle);
distributionSplitOrderDetailService.update(Wrappers.<DistributionSplitOrderDetailEntity>lambdaUpdate()
.eq(DistributionSplitOrderDetailEntity::getSplitOrderTaskId, taskId)
.set(DistributionSplitOrderDetailEntity::getState, OrderPackageSplitStateConstant.cancel.getValue())
.set(DistributionSplitOrderDetailEntity::getCancelUser, AuthUtil.getUser().getUserId())
.set(DistributionSplitOrderDetailEntity::getCancelUsername, AuthUtil.getUser().getUserName())
);
distributionSplitOrderLogService.record(task, "取消拆单任务", AuthUtil.getUser().getUserName());
allTask.setNumber(allTask.getNumber() - 1);
allTask.setOrderPackageNumber(allTask.getOrderPackageNumber() - task.getTaskNumber());
distributionSplitOrderAllTaskService.updateById(allTask);
task.setIsDeleted(1);
task.setNumber(0);
updateById(task);
cancelTask(task);
return R.success("success");
} catch (Exception e) {
log.error("取消拆单任务系统错误", e);
@ -607,6 +597,9 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
if (task == null) {
return R.fail("拆单任务不存在");
}
if (!task.getState().equals(OrderSplitStateConstant.InProgress.getValue())) {
return R.fail("拆单任务不在进行中,无法取消");
}
long count = distributionSplitOrderDetailService.count(Wrappers.<DistributionSplitOrderDetailEntity>lambdaQuery()
.in(DistributionSplitOrderDetailEntity::getOrderPackageCode, packageCodes)
@ -621,11 +614,6 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
msg += "等" + packageCodes.size() + "个包件";
}
if (task.getNumber() == packageCodes.size()) {
distributionSplitOrderLogService.record(task, String.format("取消包件:%s", msg), AuthUtil.getUser().getUserName());
return deleteTask(taskId);
}
try{
distributionSplitOrderDetailService.update(Wrappers.<DistributionSplitOrderDetailEntity>lambdaUpdate()
@ -702,6 +690,10 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
newOrder.setTotalNumber(packageList.size());
newOrder.setHandQuantity(packageList.size());
newOrder.setIncomingNum(packageList.size());
newOrder.setCustomerAddress(task.getCustomerAddress());
newOrder.setCustomerName(task.getCustomerName());
newOrder.setCustomerTelephone(task.getCustomerTelephone());
if (newOrder.getId() != null) {
distributionStockArticleService.updateById(newOrder);
}else{
@ -730,7 +722,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
@Override
public R<String> cancelTask(Long taskId) {
DistributionSplitOrderTaskEntity task = getById(taskId);
if (!task.getState().equals(OrderSplitStateConstant.InProgress.getValue())) {
if (!task.getState().equals(OrderSplitStateConstant.finish.getValue())) {
return R.fail("任务未已完成,无法操作");
}
DistributionSplitOrderAllTaskEntity allTask = distributionSplitOrderAllTaskService.getById(task.getSplitOrderAllTaskId());
@ -739,19 +731,22 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
}
try {
cancelTask(task);
task.setState(OrderSplitStateConstant.InProgress.getValue());
updateById(task);
} catch (Exception e) {
if (e instanceof CustomerException) {
throw new CustomerException(e.getMessage());
}
log.error("撤消拆单任务系统错误", e);
log.error("拆单任务取消完成系统错误", e);
throw new CustomerException("系统错误");
}
return R.success("操作成功");
}
/**
* 撤销任务
*/
public void cancelTask(DistributionSplitOrderTaskEntity task){
task.setState(OrderSplitStateConstant.cancel.getValue());
updateById(task);
@ -914,16 +909,18 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
}
List<DistributionSplitOrderAllTaskEntity> list = distributionSplitOrderAllTaskService.list(page, queryWrapper);
String createUserIds = list.stream().map((d) -> d.getCreateUser() + "").collect(Collectors.joining(","));
List<User> users = iUserClient.userInfoByIds(AuthUtil.getTenantId(), String.join(",", createUserIds)).getData();
Map<Long, User> userMap = users.stream().collect(Collectors.toMap(User::getId, u -> u));
List<DistributionSplitOrderAllTaskVO> listVo = list.stream().map(d -> {
DistributionSplitOrderAllTaskVO vo = new DistributionSplitOrderAllTaskVO();
BeanUtil.copyProperties(d, vo);
vo.setCreateUserName(userMap.get(d.getCreateUser()).getName());
return vo;
}).collect(Collectors.toList());
List<DistributionSplitOrderAllTaskVO> listVo = new ArrayList<>();
if (list != null && !list.isEmpty()) {
Map<Long, String> userMap = getUserIdNameMap(list.stream().map(DistributionSplitOrderAllTaskEntity::getCreateUser).collect(Collectors.toList()));
Map<Long, Long> allTaskIdPackageNumber = getAllTaskIdPackageNumber(list.stream().map(DistributionSplitOrderAllTaskEntity::getId).collect(Collectors.toList()));
listVo = list.stream().map(d -> {
DistributionSplitOrderAllTaskVO vo = new DistributionSplitOrderAllTaskVO();
BeanUtil.copyProperties(d, vo);
vo.setCreateUserName(userMap.get(d.getCreateUser()));
vo.setSplitPackageNumber(allTaskIdPackageNumber.get(d.getId()));
return vo;
}).collect(Collectors.toList());
}
pageResult.setRecords(listVo);
pageResult.setPages(page.getPages());
@ -932,6 +929,22 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
return R.data(pageResult);
}
private Map<Long, Long> getAllTaskIdPackageNumber(List<Long> taskIds){
List<Map<String, Object>> maps = baseMapper.selectMaps(
Wrappers.<DistributionSplitOrderTaskEntity>query()
.select("split_order_all_task_id", "SUM(number) as number")
.eq("split_order_all_task_id", taskIds)
.in("state", OrderSplitStateConstant.InProgress.getValue(), OrderSplitStateConstant.finish.getValue())
.groupBy("split_order_all_task_id")
);
return maps.stream().collect(Collectors.toMap(
m -> Long.valueOf(m.get("split_order_all_task_id").toString()),
m -> Long.valueOf(m.get("number").toString())
));
}
@Override
public R<Object> getTaskDetail(Long taskId) {
R<List<SplitPackageOrderVO>> PackageOrderList = getPackageCodeByTaskId(taskId);
@ -944,6 +957,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl<Distr
res.put("packageList", PackageOrderList.getData());
res.put("logList", logList);
res.put("info", getById(taskId));
return R.data(res);
}

5
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/vo/DistributionSplitOrderAllTaskVO.java

@ -7,5 +7,10 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DistributionSplitOrderAllTaskVO extends DistributionSplitOrderAllTaskEntity {
private String createUserName;
/**
* 已拆单包件数量
*/
private Long splitPackageNumber;
}

14
blade-service/logpm-factory-data/logpm-factory-data-paterson/Dockerfile

@ -0,0 +1,14 @@
FROM 192.168.2.110:7777/hwy/hwy_base:v1.0
MAINTAINER h5u@163.com
RUN mkdir -p /logpm/logpm-factory-data-paterson
WORKDIR /logpm/logpm-factory-data-paterson
EXPOSE 19010
ADD ./target/logpm-factory-data-paterson.jar ./app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar","-Xms128m","-Xmx512m", "app.jar"]
CMD ["--spring.profiles.active=test"]

96
blade-service/logpm-factory-data/logpm-factory-data-paterson/pom.xml

@ -0,0 +1,96 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springblade</groupId>
<artifactId>logpm-factory-data</artifactId>
<version>3.2.0.RELEASE</version>
</parent>
<artifactId>logpm-factory-data-paterson</artifactId>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-auto</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-factory-data-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-trunkline-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-factory-data-base-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-oss</artifactId>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-resource-api</artifactId>
<version>3.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

20
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/FactoryDataPatersonApplication.java

@ -0,0 +1,20 @@
package com.logpm.factorydata;
import org.springblade.common.constant.ModuleNameConstant;
import org.springblade.core.cloud.client.BladeCloudApplication;
import org.springblade.core.launch.BladeApplication;
/**
* 索菲亚工厂数据启动类
*
* @author zhaoqiaobo
* @create 2024-4-26
*/
@BladeCloudApplication
public class FactoryDataPatersonApplication {
public static void main(String[] args) {
BladeApplication.run(ModuleNameConstant.LOGPM_FACTORY_DATA_PATERSON_NAME, FactoryDataPatersonApplication.class, args);
}
}

50
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/AsyncAnnotationAspect.java

@ -0,0 +1,50 @@
package com.logpm.factorydata.paterson.aspect;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springblade.common.annotations.LogpmAsync;
import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
@Aspect
@Component
@Slf4j
@Order(-1)
public class AsyncAnnotationAspect {
/**
* 定义一个切点匹配所有带有@LogpmAsync("asyncExecutor")注解的方法
* 注意实际上Spring Framework自带对@LogpmAsync("asyncExecutor")的处理直接这样配置可能会导致预期之外的行为
*/
//@Around("@annotation(org.springblade.common.annotations.LogpmAsync)")
public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
LogpmAsync myAsync = method.getAnnotation(LogpmAsync.class);
String annotationValue = myAsync.value();
log.info(">>>>>>>>>>>>>>>>>> annotationValue={}",annotationValue);
log.info("@LogpmAsync注解的值为asyncExecutor,进行数据源切换 ");
// 在方法执行前的操作
String tenantId = AuthUtil.getTenantId();
log.info(">> tenandId {} ",tenantId);
DynamicDataSourceContextHolder.push(tenantId);
// 执行原方法
Object result = joinPoint.proceed();
// 在方法执行后的操作
DynamicDataSourceContextHolder.poll();
return result;
}
}

82
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/JobAnnotationAspect.java

@ -0,0 +1,82 @@
package com.logpm.factorydata.paterson.aspect;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.AllArgsConstructor;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springblade.common.cache.CacheNames;
import org.springblade.common.component.MockLoginService;
import org.springblade.common.utils.DefaultUserTokenConfig;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.redis.lock.LockType;
import org.springblade.core.redis.lock.RedisLockClient;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Aspect
@Component
@AllArgsConstructor
public class JobAnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
private final RedisLockClient redisLockClient;
private final MockLoginService mockLoginService;
@Around("@annotation(com.xxl.job.core.handler.annotation.XxlJob)")
public Object xxlJobAnnotationMethods(ProceedingJoinPoint joinPoint) throws Throwable {
JSONObject jsonObject = mockLogin();
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.addHeader("Blade-Auth", "bearer "+jsonObject.get("access_token"));
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Blade-Auth","bearer "+jsonObject.get("access_token") );
httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0");
ThreadLocalUtil.put("bladeContext", httpHeaders);
DynamicDataSourceContextHolder.push(jsonObject.getString("tenant_id"));
// 执行原方法
Object result = joinPoint.proceed();
// 在方法执行后,从数据源上下文中移除租户ID
DynamicDataSourceContextHolder.poll();
return result;
}
private JSONObject mockLogin() throws InterruptedException {
String account ="shujutongbu";
String tenantId ="627683";
String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account;
String lockKey =key+":lock";
JSONObject data =bladeRedis.get(key);
if(Objects.isNull(data)){
boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS);
if(flag){
data =bladeRedis.get(key);
if(Objects.isNull(data)){
data = mockLoginService.mockToken(tenantId,account);
bladeRedis.setEx(key,data, DefaultUserTokenConfig.EXPIRE_TIME);
redisLockClient.unLock(lockKey, LockType.FAIR);
}
}
}
return data;
}
}

48
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/aspect/RabbitAnnotationAspect.java

@ -0,0 +1,48 @@
package com.logpm.factorydata.paterson.aspect;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.stereotype.Component;
@Aspect
@Component
@Slf4j
public class RabbitAnnotationAspect {
/**
* 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能
*
* @param joinPoint 切面的连接点表示当前被拦截的方法
* @return 返回被拦截方法的执行结果
* @throws Throwable 如果执行过程中发生异常则抛出
*/
@Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener)")
public Object rabbitMethods(ProceedingJoinPoint joinPoint) throws Throwable {
// 在方法执行前,获取当前租户ID并设置到数据源上下文中
String tenantId = AuthUtil.getTenantId();
DynamicDataSourceContextHolder.push(tenantId);
// 执行原方法
Object result = joinPoint.proceed();
// 在方法执行后,从数据源上下文中移除租户ID
DynamicDataSourceContextHolder.poll();
return result;
}
@Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)")
public Object rabbitHandlerMethods(ProceedingJoinPoint joinPoint) throws Throwable {
// 在方法执行前,获取当前租户ID并设置到数据源上下文中
String tenantId = AuthUtil.getTenantId();
DynamicDataSourceContextHolder.push(tenantId);
// 执行原方法
Object result = joinPoint.proceed();
// 在方法执行后,从数据源上下文中移除租户ID
DynamicDataSourceContextHolder.poll();
return result;
}
}

161
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/CustomMessageConverter.java

@ -0,0 +1,161 @@
package com.logpm.factorydata.paterson.config;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter;
import org.springframework.amqp.support.converter.MessageConversionException;
import org.springframework.amqp.utils.SerializationUtils;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
/**
* @author zhaoqiaobo
* @create 2024-05-08
*/
@Component
public class CustomMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware {
private volatile String defaultCharset = "UTF-8";
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
private String codebaseUrl;
@Deprecated
public void setCodebaseUrl(String codebaseUrl) {
this.codebaseUrl = codebaseUrl;
}
@Override
public Object fromMessage(Message message) throws MessageConversionException {
Object content = null;
MessageProperties properties = message.getMessageProperties();
if (properties != null) {
String contentType = properties.getContentType();
if (contentType != null && contentType.startsWith("text")) {
String encoding = properties.getContentEncoding();
if (encoding == null) {
encoding = "UTF-8";
}
try {
content = new String(message.getBody(), encoding);
} catch (UnsupportedEncodingException var8) {
throw new MessageConversionException("failed to convert text-based Message content", var8);
}
} else if (contentType != null && contentType.equals("application/x-java-serialized-object")) {
try {
content = SerializationUtils.deserialize(this.createObjectInputStream(new ByteArrayInputStream(message.getBody()), this.codebaseUrl));
} catch (IllegalArgumentException | IllegalStateException | IOException var7) {
throw new MessageConversionException("failed to convert serialized Message content", var7);
}
}
}
Map<String, Object> headers = properties.getHeaders();
HttpHeaders httpHeaders = new HttpHeaders();
for (Map.Entry<String, Object> entry : headers.entrySet()) {
if (StrUtil.equals("Blade-Auth", entry.getKey())
|| StrUtil.equals("Authorization", entry.getKey())
|| StrUtil.equals("blade-auth", entry.getKey())
|| StrUtil.equals("authorization", entry.getKey())) {
List value = (List) entry.getValue();
for (Object o : value) {
httpHeaders.add(entry.getKey(), String.valueOf(o));
}
}
}
ThreadLocalUtil.put("bladeContext", httpHeaders);
Object bladeUser = headers.get("bladeUser");
MockHttpServletRequest request = new MockHttpServletRequest();
BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class);
request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1);
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
if (content == null) {
content = message.getBody();
}
return content;
}
@Override
protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException {
byte[] bytes = null;
if (object instanceof byte[]) {
bytes = (byte[]) object;
messageProperties.setContentType("application/octet-stream");
} else if (object instanceof String) {
try {
bytes = ((String) object).getBytes(this.defaultCharset);
} catch (UnsupportedEncodingException var6) {
throw new MessageConversionException("failed to convert to Message content", var6);
}
messageProperties.setContentType("text/plain");
messageProperties.setContentEncoding(this.defaultCharset);
} else if (object instanceof Serializable) {
try {
bytes = SerializationUtils.serialize(object);
} catch (IllegalArgumentException var5) {
throw new MessageConversionException("failed to convert to serialized Message content", var5);
}
messageProperties.setContentType("application/x-java-serialized-object");
}
HttpHeaders headers = (HttpHeaders) ThreadLocalUtil.get("bladeContext");
if (headers != null && !headers.isEmpty()) {
headers.forEach((key, values) -> {
values.forEach((value) -> {
messageProperties.setHeader(key, new String[]{value});
});
});
}
BladeUser user = AuthUtil.getUser();
BladeUser bladeUser = new BladeUser();
bladeUser.setTenantId(user.getTenantId());
bladeUser.setUserId(user.getUserId());
bladeUser.setAccount(user.getAccount());
bladeUser.setRoleId(user.getRoleId());
messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser));
if (bytes != null) {
messageProperties.setContentLength((long) bytes.length);
return new Message(bytes, messageProperties);
} else {
throw new IllegalArgumentException(this.getClass().getSimpleName() + " only supports String, byte[] and Serializable payloads, received: " + object.getClass().getName());
}
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = beanClassLoader;
}
protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException {
return new CodebaseAwareObjectInputStream(is, this.beanClassLoader, codebaseUrl) {
@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
Class<?> clazz = super.resolveClass(classDesc);
CustomMessageConverter.this.checkAllowedList(clazz);
return clazz;
}
};
}
}

85
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/ExecutorConfig.java

@ -0,0 +1,85 @@
package com.logpm.factorydata.paterson.config;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
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.Map;
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(50);
// 配置线程池中线程的名称前缀
threadPoolTaskExecutor.setThreadNamePrefix("ASYNC_THREAD_");
// 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();
String tenantId = AuthUtil.getTenantId();
Map<String, Object> all = ThreadLocalUtil.getAll();
Map<String, String> mdcMap = MDC.getCopyOfContextMap();
return () -> {
try {
all.keySet().forEach(key -> ThreadLocalUtil.put(key, all.get(key)));
if (mdcMap != null && !mdcMap.isEmpty()) {
MDC.setContextMap(mdcMap);
}
RequestContextHolder.setRequestAttributes(context);
// 未当前的异步线程绑定租户ID 和切换数据源
log.info(">>>> 异步线程创建,绑定租户数据源 {}",tenantId);
DynamicDataSourceContextHolder.push(tenantId);
runnable.run();
} finally {
RequestContextHolder.resetRequestAttributes();
all.clear();
if (mdcMap != null) {
mdcMap.clear();
}
ThreadLocalUtil.clear();
MDC.clear();
DynamicDataSourceContextHolder.poll();
}
};
}
}
}

40
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/FactoryDataPatersonConfiguration.java

@ -0,0 +1,40 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package com.logpm.factorydata.paterson.config;
import com.logpm.factorydata.paterson.pros.FactoryDataPatersonProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* 配置feignmybatis包名properties
*
* @author chaos
*/
@Configuration(proxyBeanMethods = false)
@ComponentScan({"org.springblade", "com.logpm"})
@EnableFeignClients({"org.springblade", "com.logpm"})
@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"})
@EnableConfigurationProperties(FactoryDataPatersonProperties.class)
public class FactoryDataPatersonConfiguration {
}

39
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/InterceptorAdapterConfig.java

@ -0,0 +1,39 @@
package com.logpm.factorydata.paterson.config;
import com.logpm.factorydata.paterson.interceptor.FactoryAccountsInterceptor;
import com.logpm.factorydata.paterson.pros.PatersonProperties;
import com.logpm.factorydata.paterson.service.FactoryShipmentService;
import org.springblade.common.component.MockLoginService;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.redis.lock.RedisLockClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
@Configuration
public class InterceptorAdapterConfig implements WebMvcConfigurer {
@Resource
private BladeRedis redis;
@Resource
private Environment environment;
@Resource
private RedisLockClient redisLockClient;
@Resource
private MockLoginService mockLoginService;
@Lazy
@Resource
private FactoryShipmentService jpFactoryShipmentService;
@Resource
private PatersonProperties jinPaiProperties;
@Override
public void addInterceptors(InterceptorRegistry interceptorRegistry) {
interceptorRegistry.addInterceptor(new FactoryAccountsInterceptor(redis, environment, redisLockClient, mockLoginService, jinPaiProperties, jpFactoryShipmentService))
.addPathPatterns("/order/v1").order(3);
}
}

17
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/RabbitConfig.java

@ -0,0 +1,17 @@
package com.logpm.factorydata.paterson.config;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory factory) {
RabbitTemplate template = new RabbitTemplate(factory);
template.setMessageConverter(new CustomMessageConverter());
return template;
}
}

74
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/config/XxlJobConfig.java

@ -0,0 +1,74 @@
package com.logpm.factorydata.paterson.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* xxl-job config
*
* @author xuxueli 2017-04-28
*/
@Configuration(proxyBeanMethods = false)
public class XxlJobConfig {
private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
/**
* 针对多网卡容器内部署等情况可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP
*
* 1引入依赖
* <dependency>
* <groupId>org.springframework.cloud</groupId>
* <artifactId>spring-cloud-commons</artifactId>
* <version>${version}</version>
* </dependency>
*
* 2配置文件或者容器启动变量
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
*
* 3获取IP
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
*/
}

64
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/controller/OrderController.java

@ -0,0 +1,64 @@
package com.logpm.factorydata.paterson.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.factorydata.paterson.service.FactoryShipmentService;
import com.logpm.factorydata.paterson.vo.FactoryOrderDataVO;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 工厂订单 前端控制器
*
* @author zhaoqiaobo
* @create 2024-03-21 19:27
*/
@Slf4j
@RestController
@RequestMapping("/order")
@AllArgsConstructor
@Api(value = "工厂订单", tags = "工厂订单")
public class OrderController {
@Lazy
@Resource
private FactoryShipmentService shipmentService;
@ResponseBody
@PostMapping("/v1")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "百得胜-工厂订单", notes = "百得胜-工厂订单")
public R orderV1(@RequestBody FactoryOrderDataVO vo) {
String jsonStr = JSONUtil.toJsonStr(vo);
log.info("接收百得胜工厂订单:{} ", jsonStr);
String res = "";
try {
String params = vo.getParams();
if(StrUtil.isNotEmpty(params)){
FactoryShipmentVO bean = JSONUtil.toBean(params, FactoryShipmentVO.class);
if (ObjectUtil.isNotEmpty(bean)) {
res = shipmentService.shipment(bean);
}
}
} catch (Exception e) {
log.error("百得胜工厂订单异常:{} ", e);
return R.fail("服务器异常");
}
return R.success(res);
}
}

88
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderEntity.java

@ -0,0 +1,88 @@
package com.logpm.factorydata.paterson.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* 百得胜工厂订单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@TableName("bds_factory_order")
@ApiModel(value = "百得胜工厂订单", description = "百得胜工厂订单")
@EqualsAndHashCode(callSuper = true)
public class FactoryOrderEntity extends BaseEntity {
@ApiModelProperty(name = "日志id")
private String logId;
@ApiModelProperty(name = "发货单id")
private Long shipmentId;
@ApiModelProperty(name = "订单号")
private String orderCode;
@ApiModelProperty(name = "交割单号/服务号")
private String serviceNum;
@ApiModelProperty(name = "服务类型")
private String serverType;
@ApiModelProperty(name = "结算方式")
private String settlementType;
@ApiModelProperty(name = "是否补件")
private String supplement;
@ApiModelProperty(name = "发运方式")
private String shipVia;
@ApiModelProperty(name = "订单总件数")
private Integer totalQuantity;
@ApiModelProperty(name = "商场名称")
private String mallName;
@ApiModelProperty(name = "商场编码")
private String mallCode;
@ApiModelProperty(name = "商场电话")
private String mallMobile;
@ApiModelProperty(name = "商场地址")
private String mallAddress;
@ApiModelProperty(name = "商场收货人")
private String mallConsignee;
@ApiModelProperty(name = "商场收货人电话")
private String mallConsigneeMobile;
@ApiModelProperty(name = "门店名称")
private String storeName;
@ApiModelProperty(name = "门店编码")
private String storeCode;
@ApiModelProperty(name = "门店电话")
private String storeMobile;
@ApiModelProperty(name = "门店地址")
private String storeAddress;
@ApiModelProperty(name = "门店收货人")
private String storeConsignee;
@ApiModelProperty(name = "门店收货人电话")
private String storeConsigneeMobile;
@ApiModelProperty(name = "终端收货人")
private String receiverName;
@ApiModelProperty(name = "终端收货人电话")
private String receiverMobile;
@ApiModelProperty(name = "终端收货人地址")
private String receiverAddress;
@ApiModelProperty(name = "备注")
private String remark;
@ApiModelProperty(name = "是否确认")
private Boolean checked;
@ApiModelProperty(name = "租户")
private String tenantCode;
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
}

63
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryOrderLogEntity.java

@ -0,0 +1,63 @@
package com.logpm.factorydata.paterson.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
@Data
@TableName("bds_factory_log")
@ApiModel(value = "接收工厂订单日志", description = "接收工厂订单日志")
@EqualsAndHashCode(callSuper = true)
public class FactoryOrderLogEntity extends BaseEntity {
/**
* 预留1
*/
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
/**
* 预留2
*/
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
/**
* 预留3
*/
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
/**
* 预留4
*/
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
/**
* 预留5
*/
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
/**
* 日志文件存放地址
*/
@ApiModelProperty(name = "日志文件存放地址", notes = "")
private String logUrl;
/**
* 数据类型 1.拉取数据 2推送数据
*/
@ApiModelProperty(name = "数据类型 1.拉取数据 2。推送数据", notes = "")
private Integer type;
/**
* 数据维度1 订单 2 订单明细 3 包件
*/
@ApiModelProperty(name = "维度:1 订单 2 订单明细 3 包件", notes = "")
private Integer dimension;
/**
* 解析状态 0 未解析 1 解析失败 2 已解析
*/
@ApiModelProperty(name = "解析状态 0 未解析 1 解析失败 2 已解析", notes = "")
private Integer saxStatus;
}

72
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryPackageEntity.java

@ -0,0 +1,72 @@
package com.logpm.factorydata.paterson.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* 百得胜工厂包件 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@TableName("bds_factory_package")
@ApiModel(value = "百得胜工厂包件", description = "百得胜工厂包件")
@EqualsAndHashCode(callSuper = true)
public class FactoryPackageEntity extends BaseEntity {
@ApiModelProperty(name = "日志id")
private String logId;
@ApiModelProperty(name = "订单id")
private Long orderId;
@ApiModelProperty(name = "是否合包")
@JsonProperty("isConsolidation")
private String consolidation;
@ApiModelProperty(name = "合包码")
private String consolidationCode;
@ApiModelProperty(name = "包件码")
private String unitNo;
@ApiModelProperty(name = "产品编号")
private String productCode;
@ApiModelProperty(name = "产品名称")
private String productName;
@ApiModelProperty(name = "件数")
private Integer quantity;
@ApiModelProperty(name = "体积")
private Double volume;
@ApiModelProperty(name = "重量")
private Double weight;
@ApiModelProperty(name = "一级品类名称")
private String firstPackName;
@ApiModelProperty(name = "一级品类编码")
private String firstPackCode;
@ApiModelProperty(name = "二级品类名称")
private String secondPackName;
@ApiModelProperty(name = "二级品类编码")
private String secondPackCode;
@ApiModelProperty(name = "三级品类名称")
private String thirdPackName;
@ApiModelProperty(name = "三级品类编码")
private String thirdPackCode;
@ApiModelProperty(name = "是否确认")
private Boolean checked;
@ApiModelProperty(name = "租户")
private String tenantCode;
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
}

64
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/entity/FactoryShipmentEntity.java

@ -0,0 +1,64 @@
package com.logpm.factorydata.paterson.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* 百得胜工厂发货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@TableName("bds_factory_shipment")
@ApiModel(value = "百得胜工厂发货单", description = "百得胜工厂发货单")
@EqualsAndHashCode(callSuper = true)
public class FactoryShipmentEntity extends BaseEntity {
@ApiModelProperty(name = "日志id")
private String logId;
@ApiModelProperty(name = "发货单号")
private String shipmentId;
@ApiModelProperty(name = "物流公司编码")
private String carrierCode;
@ApiModelProperty(name = "物流公司名称")
private String carrierName;
@ApiModelProperty(name = "发货基地")
private String shipmentHub;
@ApiModelProperty(name = "计划发车时间")
private String planStartTime;
@ApiModelProperty(name = "计划到达时间")
private String planEndTime;
@ApiModelProperty(name = "司机")
private String driverName;
@ApiModelProperty(name = "司机电话")
private String driverMobile;
@ApiModelProperty(name = "车牌")
private String carNumber;
@ApiModelProperty(name = "发货人名称")
private String senderName;
@ApiModelProperty(name = "发货人电话")
private String senderMobile;
@ApiModelProperty(name = "发货人地址")
private String senderAddress;
@ApiModelProperty(name = "是否确认")
private Boolean checked;
@ApiModelProperty(name = "租户")
private String tenantCode;
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
}

180
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/interceptor/FactoryAccountsInterceptor.java

@ -0,0 +1,180 @@
package com.logpm.factorydata.paterson.interceptor;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSONObject;
import com.logpm.factorydata.paterson.pros.PatersonProperties;
import com.logpm.factorydata.paterson.service.FactoryShipmentService;
import com.logpm.factorydata.paterson.vo.FactoryAuthVO;
import com.logpm.factorydata.paterson.wrapper.RequestWrapper;
import lombok.NoArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springblade.common.cache.CacheNames;
import org.springblade.common.component.MockLoginService;
import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.DefaultUserTokenConfig;
import org.springblade.common.wrapper.CustomHttpServletRequestWrapper;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.redis.lock.LockType;
import org.springblade.core.redis.lock.RedisLockClient;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.Instant;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Log4j2
@NoArgsConstructor
public class FactoryAccountsInterceptor implements HandlerInterceptor {
@Resource
private BladeRedis bladeRedis;
@Resource
private Environment environment;
@Resource
private RedisLockClient redisLockClient;
@Resource
private MockLoginService mockLoginService;
@Resource
private PatersonProperties jinPaiProperties;
@Resource
@Lazy
private FactoryShipmentService jpFactoryShipmentService;
public FactoryAccountsInterceptor(BladeRedis redis, Environment environment, RedisLockClient redisLockClient, MockLoginService mockLoginService, PatersonProperties suoFeiYaProperties, FactoryShipmentService deliveryNoteService) {
this.bladeRedis = redis;
this.environment = environment;
this.redisLockClient = redisLockClient;
this.mockLoginService = mockLoginService;
this.jinPaiProperties = suoFeiYaProperties;
this.jpFactoryShipmentService = deliveryNoteService;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException {
try {
log.info("##########preHandle: 认证开始--------------");
RequestWrapper myRequestWrapper = new RequestWrapper(request);
String body = myRequestWrapper.getBody();
log.info("##########preHandle: body={}", body);
JSONObject jsonObject = JSONObject.parseObject(body);
// 获取头中参数
String companyCode = jsonObject.getString("companyCode");
String params = jsonObject.getString("params");
String sign = jsonObject.getString("digest");
Long authTime = jsonObject.getLong("timestamp");
if (ObjectUtil.isEmpty(authTime)) {
log.info("##########preHandle: 时间戳不能为空");
returnJson(response, JSONObject.toJSONString(R.fail("时间戳不能为空")));
return false;
}
log.info("##########preHandle: authTime={},sign={},companyCodeH={}", authTime, sign, companyCode);
String account = "shujutongbu";
String tenantId = "627683";
String authorizationHeader = "bG9jYWw6bG9jYWxfc2VjcmV0";
if (StringUtil.isNotBlank(companyCode)) {
FactoryAuthVO authVO = jpFactoryShipmentService.findFactoryAuth(companyCode);
if (ObjectUtil.isNotEmpty(authVO)) {
Long authTime1 = authVO.getAuthTime();
long secondTimestamp = Instant.now().getEpochSecond();
// 验证时间 不能大于5秒
if (secondTimestamp - authTime > authTime1) {
log.info("##########preHandle: 时间戳过期");
returnJson(response, JSONObject.toJSONString(R.fail("认证不通过,时间戳过期")));
return false;
}
// 验证签名
String auth = authVO.getAppKey();
String md5Hex = Base64.encode(MD5.create().digestHex(params + auth + authTime)).toUpperCase();
log.info("##########preHandle: md5Hex={}", md5Hex);
if (!StrUtil.equals(md5Hex, sign)) {
log.info("##########preHandle: 签名不正确");
returnJson(response, JSONObject.toJSONString(R.fail("认证不通过,签名不正确")));
return false;
}
account = authVO.getLoginAccount();
tenantId = authVO.getTenantCode();
authorizationHeader = authVO.getAuthorizationHeader();
CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request);
String key = CacheNames.LOCAL_SERVER_USER + tenantId + ":" + account;
String lockKey = key + ":lock";
JSONObject data = bladeRedis.get(key);
if (Objects.isNull(data)) {
boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS);
if (flag) {
data = bladeRedis.get(key);
if (Objects.isNull(data)) {
data = mockLoginService.mockToken(tenantId, account);
bladeRedis.setEx(key, data, DefaultUserTokenConfig.EXPIRE_TIME);
redisLockClient.unLock(lockKey, LockType.FAIR);
}
}
}
// 发送登录请求
log.info("##########preHandle: request={}", request);
wrappedRequest.addHeader("Blade-Auth", "bearer " + data.getString("access_token"));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Blade-Auth", "bearer " + data.get("access_token"));
httpHeaders.add("Authorization", "Basic " + authorizationHeader);
ThreadLocalUtil.put("bladeContext", httpHeaders);
// 用包装后的request替换原始request
request = wrappedRequest;
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
return true;
}
} else {
returnJson(response, JSONObject.toJSONString(R.fail("缺少参数 companyCode")));
return false;
}
return false;
} catch (Exception e) {
e.printStackTrace();
returnJson(response, JSONObject.toJSONString(R.fail("服务异常,请联系管理员")));
return false;
}
}
private void returnJson(HttpServletResponse response, String json) {
PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
try {
writer = response.getWriter();
writer.print(json);
} catch (IOException e) {
System.out.println(e.getMessage());
} finally {
if (writer != null) {
writer.close();
}
}
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
}
}

60
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/launcher/FactoryDataBaseLauncherServiceImpl.java

@ -0,0 +1,60 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package com.logpm.factorydata.paterson.launcher;
import org.springblade.core.auto.service.AutoService;
import org.springblade.core.launch.constant.NacosConstant;
import org.springblade.core.launch.service.LauncherService;
import org.springblade.core.launch.utils.PropsUtil;
import org.springframework.boot.builder.SpringApplicationBuilder;
import java.util.Properties;
/**
* 启动参数拓展
*
* @author Chill
*/
@AutoService(LauncherService.class)
public class FactoryDataBaseLauncherServiceImpl implements LauncherService {
@Override
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
Properties props = System.getProperties();
// 开启多数据源
PropsUtil.setProperty(props, "spring.datasource.dynamic.enabled", "true");
// 指定注册配置信息
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].data-id", NacosConstant.dataId(appName, profile));
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].group", NacosConstant.NACOS_CONFIG_GROUP);
PropsUtil.setProperty(props, "spring.cloud.nacos.config.extension-configs[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH);
// 指定注册IP
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.ip", "127.0.0.1");
// 指定注册端口
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.port", "8200");
// 自定义命名空间
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.namespace", LauncherConstant.NACOS_NAMESPACE);
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.namespace", LauncherConstant.NACOS_NAMESPACE);
// 自定义分组
// PropsUtil.setProperty(props, "spring.cloud.nacos.config.group", NacosConstant.NACOS_CONFIG_GROUP);
// PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.group", NacosConstant.NACOS_CONFIG_GROUP);
}
@Override
public int getOrder() {
return 20;
}
}

16
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.paterson.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 工厂订单日志 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryOrderLogMapper extends BaseMapper<FactoryOrderLogEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderLogMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.paterson.mapper.FactoryOrderLogMapper">
</mapper>

16
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.paterson.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.paterson.entity.FactoryOrderEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 百得胜工厂订单 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryOrderMapper extends BaseMapper<FactoryOrderEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryOrderMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.paterson.mapper.FactoryOrderMapper">
</mapper>

16
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.paterson.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.paterson.entity.FactoryPackageEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 百得胜工厂包件 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryPackageMapper extends BaseMapper<FactoryPackageEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryPackageMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.paterson.mapper.FactoryPackageMapper">
</mapper>

21
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.java

@ -0,0 +1,21 @@
package com.logpm.factorydata.paterson.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity;
import com.logpm.factorydata.paterson.vo.FactoryAuthVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 百得胜工厂发货单 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryShipmentMapper extends BaseMapper<FactoryShipmentEntity> {
List<FactoryAuthVO> findFactoryAuth(@Param("companyCode") String companyCode);
}

17
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mapper/FactoryShipmentMapper.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.paterson.mapper.FactoryShipmentMapper">
<select id="findFactoryAuth" resultType="com.logpm.factorydata.paterson.vo.FactoryAuthVO">
select
logistics_code,
app_key,
auth_time,
tenant_code,
login_account,
authorization_header
from bds_factory_auth
where
company_code = #{companyCode}
</select>
</mapper>

52
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/mq/FactoryOrderListener.java

@ -0,0 +1,52 @@
package com.logpm.factorydata.paterson.mq;
import com.logpm.factorydata.paterson.service.MqWorkerService;
import com.rabbitmq.client.Channel;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import java.io.IOException;
/**
* 监听百得胜订单数据
*
* @author zhaoqiaobo
* @create 2024-03-18
*/
@Slf4j
@Component
@AllArgsConstructor
public class FactoryOrderListener {
private final MqWorkerService mqWorkerService;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.BDS_FACTORY_SHIPMENT),
exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER, type = ExchangeTypes.TOPIC),
key = FactoryDataConstants.Mq.RoutingKeys.BDS_FACTORY_SHIPMENT
), ackMode = "MANUAL")
public void factoryShipment(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
log.info("处理百得胜工厂订单:{}", msg);
try {
mqWorkerService.factoryShipment(msg);
} catch (Exception e) {
e.printStackTrace();
log.error("处理百得胜工厂订单失败: {}", e.getMessage());
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

20
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/FactoryDataPatersonProperties.java

@ -0,0 +1,20 @@
package com.logpm.factorydata.paterson.pros;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* FactoryProperties
*
* @author pref
*/
@Data
@ConfigurationProperties(prefix = "logpm")
public class FactoryDataPatersonProperties {
/**
* 名称
*/
private String name;
}

78
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/pros/PatersonProperties.java

@ -0,0 +1,78 @@
package com.logpm.factorydata.paterson.pros;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* FactoryProperties
*
* @author pref
*/
@Data
@ConfigurationProperties(prefix = "paterson")
@Component
public class PatersonProperties {
/**
* 百得胜工厂推送节点数据url
*/
private String pushNodeUrl;
/**
* 百得胜查询老数据查询老系统数据URL
*/
private String findOldDataUrl = "/openApi/jinpai/code-query";
/**
* 是否推送工厂
*/
private Boolean enable = true;
/**
* 百得胜工厂主机地址
*/
private String host;
/**
* 承运商编码
*/
private String carrierCode;
/**
* 补节点数据时的延时时间分钟
*/
private Integer delayedTime = 30;
/**
* 生成老系统暂存单
*/
private Boolean oldAdvance = false;
/**
* 生成新系统暂存单
*/
private Boolean newAdvance = false;
/**
* 老系统host
*/
private String oldSystemHost;
/**
* 老系统回传到达url
*/
private String oldSystemArrivedUrl;
/**
* 老系统回传入库url
*/
private String oldSystemAlreadyStockedUrl;
private Map<String,String> warehouse;
/** auth过期时间 */
private Long authTime = 30000L;
/** key */
private String auth;
}

14
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/DeliveryNoteService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.paterson.service;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
/**
* 索菲亚发货单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface DeliveryNoteService {
void buildFactoryAdvance(FactoryShipmentVO vo);
}

14
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderLogService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.paterson.service;
import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 工厂订单日志 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryOrderLogService extends BaseService<FactoryOrderLogEntity> {
}

14
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryOrderService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.paterson.service;
import com.logpm.factorydata.paterson.entity.FactoryOrderEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 百得胜工厂订单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryOrderService extends BaseService<FactoryOrderEntity> {
}

14
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryPackageService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.paterson.service;
import com.logpm.factorydata.paterson.entity.FactoryPackageEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 百得胜工厂包件 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryPackageService extends BaseService<FactoryPackageEntity> {
}

19
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/FactoryShipmentService.java

@ -0,0 +1,19 @@
package com.logpm.factorydata.paterson.service;
import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity;
import com.logpm.factorydata.paterson.vo.FactoryAuthVO;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
import org.springblade.core.mp.base.BaseService;
/**
* 百得胜工厂发货单 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryShipmentService extends BaseService<FactoryShipmentEntity> {
FactoryAuthVO findFactoryAuth(String companyCode);
String shipment(FactoryShipmentVO bean);
}

13
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/MqWorkerService.java

@ -0,0 +1,13 @@
package com.logpm.factorydata.paterson.service;
/**
* 消息队列工作类 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface MqWorkerService {
void factoryShipment(String msg);
}

181
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/DeliveryNoteServiceImpl.java

@ -0,0 +1,181 @@
package com.logpm.factorydata.paterson.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient;
import com.logpm.factorydata.base.vo.FactoryWarehouseBindVO;
import com.logpm.factorydata.enums.BrandEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.paterson.service.DeliveryNoteService;
import com.logpm.factorydata.paterson.vo.FactoryOrderVO;
import com.logpm.factorydata.paterson.vo.FactoryPackageVO;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
import com.logpm.factorydata.vo.SendMsg;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.annotations.LogpmAsync;
import org.springblade.common.constant.HttpConstants;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 发货单 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
public class DeliveryNoteServiceImpl implements DeliveryNoteService {
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private IOssClient ossClient;
@Resource
private IFactoryDataBaseClient baseClient;
@Override
@LogpmAsync("asyncExecutor")
public void buildFactoryAdvance(FactoryShipmentVO vo) {
// 新起线程构建暂存单发送mq
Long startWarehouseId = null;
String startWarehouseName = null;
String tenantId = null;
// 获取工厂基地绑定的始发仓信息
List<FactoryOrderVO> details = vo.getOrderList();
if (CollUtil.isEmpty(details)) {
return;
}
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.BDS.getValue(), vo.getShipmentHub());
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
if (ObjectUtil.isNotNull(data)) {
startWarehouseId = data.getWarehouseId();
startWarehouseName = data.getWarehouseName();
tenantId = data.getTenantId();
}
}
// 一个dd单号 一个暂存单
// 组装暂存单数据
List<JSONObject> advances = new ArrayList<>();
for (FactoryOrderVO orderInfoVO : details) {
List<JSONObject> packageList = new ArrayList<>();
TrunklineAdvanceEntity advanceEntity = new TrunklineAdvanceEntity();
Boolean checked = vo.getChecked();
if (checked) {
advanceEntity.setReserve2("1");
} else {
advanceEntity.setReserve2("0");
}
advanceEntity.setTenantId(tenantId);
advanceEntity.setStatus(0);
advanceEntity.setIsDeleted(0);
advanceEntity.setHasPackage(1);
advanceEntity.setOrderType("");
advanceEntity.setBrand(BrandEnums.BDS.getValue());
advanceEntity.setSiteName(vo.getShipmentHub());
advanceEntity.setArea("");
advanceEntity.setTotalNum(CollUtil.isNotEmpty(orderInfoVO.getPackageList()) ? orderInfoVO.getPackageList().size() : 0);
advanceEntity.setPackName("");
advanceEntity.setPackCode("");
advanceEntity.setWarehouseId(startWarehouseId);
advanceEntity.setWarehouseName(startWarehouseName);
advanceEntity.setIsGcp(0);
advanceEntity.setCarrierName("");
advanceEntity.setSystemType("线上");
advanceEntity.setMatingType("1");
advanceEntity.setSenderName("");
advanceEntity.setSenderPhone("");
advanceEntity.setSenderAddress("");
advanceEntity.setWaybillStatus("0");
advanceEntity.setWaybillNo("");
advanceEntity.setTrainNumber(vo.getShipmentId());
advanceEntity.setFreezeStatus("0");
advanceEntity.setOrderCode(orderInfoVO.getOrderCode());
advanceEntity.setServiceNum(orderInfoVO.getServiceNum());
advanceEntity.setSenderFactory("百得胜");
// 门店是商场
// advanceEntity.setDealerCode(orderInfoVO.getShopCode());
advanceEntity.setDealerName(orderInfoVO.getMallName());
// advanceEntity.setStoreCode(orderInfoVO.getShopCode());
advanceEntity.setStoreName(orderInfoVO.getStoreName());
// 安装是客户
advanceEntity.setCustomerName(orderInfoVO.getReceiverName());
advanceEntity.setCustomerPhone(orderInfoVO.getReceiverMobile());
advanceEntity.setCustomerAddress(orderInfoVO.getReceiverAddress());
// 收货人就是商场收货人
advanceEntity.setConsigneePerson(orderInfoVO.getMallConsignee());
advanceEntity.setConsigneeMobile(orderInfoVO.getMallConsigneeMobile());
advanceEntity.setConsigneeAddress(orderInfoVO.getMallAddress());
// 封装包件品类信息
for (FactoryPackageVO packageInfoVO : orderInfoVO.getPackageList()) {
// 封装包件
TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity();
advanceDetailEntity.setWarehouseId(startWarehouseId);
advanceDetailEntity.setWarehouseName(startWarehouseName);
advanceDetailEntity.setOrderCode(orderInfoVO.getOrderCode());
advanceDetailEntity.setBrand(BrandEnums.BDS.getValue());
advanceDetailEntity.setSystemType("线上");
// 获取映射品类信息
advanceDetailEntity.setFirstPackName(packageInfoVO.getFirstPackName());
advanceDetailEntity.setFirstPackCode(packageInfoVO.getFirstPackCode());
advanceDetailEntity.setSecondPackName(packageInfoVO.getSecondPackName());
advanceDetailEntity.setSecondPackCode(packageInfoVO.getSecondPackCode());
advanceDetailEntity.setThirdPackName(packageInfoVO.getThirdPackName());
advanceDetailEntity.setThirdPackCode(packageInfoVO.getThirdPackCode());
advanceDetailEntity.setSiteName(vo.getShipmentHub());
advanceDetailEntity.setSiteCode("");
advanceDetailEntity.setQuantity(1);
advanceDetailEntity.setOrderPackageCode(packageInfoVO.getUnitNo());
advanceDetailEntity.setTrainNumber(vo.getShipmentId());
advanceDetailEntity.setServiceNum(orderInfoVO.getServiceNum());
advanceDetailEntity.setWaybillNo("");
advanceDetailEntity.setPackageStatus("0");
advanceDetailEntity.setWeight(NumberUtil.toBigDecimal(packageInfoVO.getWeight()));
advanceDetailEntity.setVolume(NumberUtil.toBigDecimal(packageInfoVO.getVolume()));
// advanceDetailEntity.setChargeType(0);
advanceDetailEntity.setSupple("");
advanceDetailEntity.setManifest("");
advanceDetailEntity.setReturnNum("");
advanceDetailEntity.setSendDateStr(DateUtil.formatLocalDateTime(LocalDateTime.now()));
advanceDetailEntity.setCarNumber("");
advanceDetailEntity.setGoodsMan("");
advanceDetailEntity.setTenantId(tenantId);
advanceDetailEntity.setStatus(0);
advanceDetailEntity.setIsDeleted(0);
JSONObject entries = JSONUtil.parseObj(advanceDetailEntity);
packageList.add(entries);
}
// 转成json对象,然后将包件明细放到detail中
JSONObject entries = JSONUtil.parseObj(advanceEntity);
entries.set("details", JSONUtil.toJsonStr(packageList));
advances.add(entries);
}
// 将组装好的暂存单发送到 MQ ,由暂存单服务统一消费SendMsg.
if (CollUtil.isNotEmpty(advances)) {
for (JSONObject advance : advances) {
SendMsg sendMsg = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.ADVANCE_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.ADVANCE_ORDER).message(JSONUtil.toJsonStr(advance)).build();
factoryDataClient.sendMessage(sendMsg);
}
}
}
}

22
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderLogServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.paterson.service.impl;
import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.paterson.mapper.FactoryOrderLogMapper;
import com.logpm.factorydata.paterson.service.FactoryOrderLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 工厂订单日志 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class FactoryOrderLogServiceImpl extends BaseServiceImpl<FactoryOrderLogMapper, FactoryOrderLogEntity> implements FactoryOrderLogService {
}

22
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryOrderServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.paterson.service.impl;
import com.logpm.factorydata.paterson.entity.FactoryOrderEntity;
import com.logpm.factorydata.paterson.mapper.FactoryOrderMapper;
import com.logpm.factorydata.paterson.service.FactoryOrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 百得胜工厂订单 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class FactoryOrderServiceImpl extends BaseServiceImpl<FactoryOrderMapper, FactoryOrderEntity> implements FactoryOrderService {
}

22
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryPackageServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.paterson.service.impl;
import com.logpm.factorydata.paterson.entity.FactoryPackageEntity;
import com.logpm.factorydata.paterson.mapper.FactoryPackageMapper;
import com.logpm.factorydata.paterson.service.FactoryPackageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* 百得胜工厂包件 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class FactoryPackageServiceImpl extends BaseServiceImpl<FactoryPackageMapper, FactoryPackageEntity> implements FactoryPackageService {
}

137
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/FactoryShipmentServiceImpl.java

@ -0,0 +1,137 @@
package com.logpm.factorydata.paterson.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity;
import com.logpm.factorydata.paterson.mapper.FactoryShipmentMapper;
import com.logpm.factorydata.paterson.service.FactoryOrderLogService;
import com.logpm.factorydata.paterson.service.FactoryShipmentService;
import com.logpm.factorydata.paterson.vo.FactoryAuthVO;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
import com.logpm.factorydata.vo.SendMsg;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.common.utils.FileLogsUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springblade.resource.feign.IOssClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.time.Duration;
import java.util.List;
/**
* 百得胜工厂发货单 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
public class FactoryShipmentServiceImpl extends BaseServiceImpl<FactoryShipmentMapper, FactoryShipmentEntity> implements FactoryShipmentService {
@Resource
private BladeRedis bladeRedis;
@Resource
private IOssClient ossClient;
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private FactoryOrderLogService factoryOrderLogService;
@Override
public FactoryAuthVO findFactoryAuth(String companyCode) {
// redis 缓存数据 缓存时间 1天
if (StrUtil.isNotBlank(companyCode)) {
String key = "factory-data:bds:" + companyCode;
String json = bladeRedis.get(key);
if (StrUtil.isNotBlank(json)) {
return JSONUtil.toBean(json, FactoryAuthVO.class);
} else {
List<FactoryAuthVO> factoryAuth = baseMapper.findFactoryAuth(companyCode);
if(CollUtil.isNotEmpty(factoryAuth)){
FactoryAuthVO authVO = factoryAuth.get(0);
bladeRedis.setEx(key, JSONUtil.toJsonStr(authVO), Duration.ofDays(1));
return authVO;
}
}
}
return null;
}
@Override
public String shipment(FactoryShipmentVO vo) {
// 1 上传数据到 minio 获取到地址
String url = uploadFile(JSONUtil.toJsonStr(vo));
// 2 保存地址到数据库
FactoryOrderLogEntity logEntity = new FactoryOrderLogEntity();
logEntity.setType(2);
logEntity.setSaxStatus(SaxStatusEnums.NOMAL.getCode());
logEntity.setLogUrl(url);
factoryOrderLogService.save(logEntity);
// 3 将消息发送给 mq,解析保存
SendMsg build = SendMsg.builder().exchange(FactoryDataConstants.Mq.Exchanges.FACTORY_ORDER)
.routingKey(FactoryDataConstants.Mq.RoutingKeys.BDS_FACTORY_SHIPMENT).message(JSONUtil.toJsonStr(logEntity)).build();
factoryDataClient.sendMessage(build);
return "成功";
}
private String uploadFile(String body) {
// 文本内容和保存为本地文件 并上传
String logPath = FileLogsUtil.saveFileLogs(body);
log.info(">>> 文件路径 {}", logPath);
MultipartFile multi = getMultipartFile(logPath);
// 上传到服务器
R r = ossClient.fileUpload(multi, "bds-order-logs");
if (r.isSuccess()) {
BladeFile data = (BladeFile) r.getData();
// 删除本地文件
FileUtil.del(logPath);
return data.getLink();
}
return null;
}
@NotNull
private MultipartFile getMultipartFile(String logPath) {
File file = new File(logPath);
// File 转 MultipartFile
FileItem item = new DiskFileItemFactory().createItem("file"
, MediaType.MULTIPART_FORM_DATA_VALUE
, true
, file.getName());
try (
InputStream input = Files.newInputStream(file.toPath());
OutputStream os = item.getOutputStream()) {
// 流转移
IOUtils.copy(input, os);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file: " + e, e);
}
return new CommonsMultipartFile(item);
}
}

139
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/service/impl/MqWorkerServiceImpl.java

@ -0,0 +1,139 @@
package com.logpm.factorydata.paterson.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.paterson.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.paterson.entity.FactoryOrderEntity;
import com.logpm.factorydata.paterson.entity.FactoryPackageEntity;
import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity;
import com.logpm.factorydata.paterson.service.DeliveryNoteService;
import com.logpm.factorydata.paterson.service.FactoryOrderLogService;
import com.logpm.factorydata.paterson.service.FactoryOrderService;
import com.logpm.factorydata.paterson.service.FactoryPackageService;
import com.logpm.factorydata.paterson.service.FactoryShipmentService;
import com.logpm.factorydata.paterson.service.MqWorkerService;
import com.logpm.factorydata.paterson.vo.FactoryOrderVO;
import com.logpm.factorydata.paterson.vo.FactoryPackageVO;
import com.logpm.factorydata.paterson.vo.FactoryShipmentVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* 消息队列工作类 业务实现类
*
* @Author zqb
* @Date 2024/4/26
**/
@Slf4j
@Service
@AllArgsConstructor
public class MqWorkerServiceImpl implements MqWorkerService {
private final DeliveryNoteService deliveryNoteService;
private final FactoryOrderLogService logService;
private final FactoryShipmentService jpFactoryShipmentService;
private final FactoryOrderService jpFactoryOrderService;
private final FactoryPackageService jpFactoryPackageService;
@Override
@Transactional(rollbackFor = Exception.class)
public void factoryShipment(String msg) {
if (StrUtil.isEmpty(msg)) {
log.error("消息内容为空");
return;
}
FactoryOrderLogEntity logEntity = JSONUtil.toBean(msg, FactoryOrderLogEntity.class);
if (ObjectUtil.isEmpty(logEntity)) {
log.error("消息内容为空");
return;
}
// 去 minio 下载文件到本地,然后解析文件内容为实体对象
FactoryShipmentVO pushOrderVO = null;
String logUrl = logEntity.getLogUrl();
if (StrUtil.isNotEmpty(logUrl)) {
List<String> res = new ArrayList<>();
FileUtil.readLines(URLUtil.url(logUrl), CharsetUtil.CHARSET_UTF_8, res);
if (CollUtil.isNotEmpty(res)) {
String content = res.get(0);
if (StrUtil.isNotEmpty(content)) {
pushOrderVO = JSONUtil.toBean(content, FactoryShipmentVO.class);
}
}
}
shipmentData(pushOrderVO, logEntity);
}
private void shipmentData(FactoryShipmentVO vo, FactoryOrderLogEntity logEntity) {
if (ObjectUtil.isNotEmpty(vo)) {
// 1 解析数据保存入库
// 装车单号唯一
Long logId = logEntity.getId();
String truckNo = vo.getShipmentId();
if (StrUtil.isEmpty(truckNo)) {
return;
}
List<FactoryShipmentEntity> list = jpFactoryShipmentService.list(Wrappers.<FactoryShipmentEntity>lambdaQuery().eq(FactoryShipmentEntity::getShipmentId, truckNo));
Boolean checked = Boolean.FALSE;
if (CollUtil.isNotEmpty(list)) {
if (list.size() > 1) {
return;
}
checked = Boolean.TRUE;
}
vo.setChecked(checked);
vo.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
vo.setTenantCode(AuthUtil.getTenantId());
jpFactoryShipmentService.save(vo);
List<FactoryOrderVO> orderVOS = vo.getOrderList();
if (CollUtil.isNotEmpty(orderVOS)) {
List<FactoryPackageEntity> packageEntities = new ArrayList<>();
for (FactoryOrderVO orderVO : orderVOS) {
FactoryOrderEntity orderEntity = new FactoryOrderEntity();
BeanUtil.copyProperties(orderVO, orderEntity);
orderEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
orderEntity.setShipmentId(vo.getId());
orderEntity.setChecked(checked);
orderEntity.setTenantCode(AuthUtil.getTenantId());
jpFactoryOrderService.save(orderEntity);
List<FactoryPackageVO> packageList = orderVO.getPackageList();
if (CollUtil.isNotEmpty(packageList)) {
for (FactoryPackageVO jpFactoryPackageVO : packageList) {
FactoryPackageEntity packageEntity = new FactoryPackageEntity();
BeanUtil.copyProperties(jpFactoryPackageVO, packageEntity);
packageEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null);
packageEntity.setOrderId(orderEntity.getId());
packageEntity.setChecked(checked);
packageEntity.setTenantCode(AuthUtil.getTenantId());
packageEntities.add(packageEntity);
}
}
}
if (CollUtil.isNotEmpty(packageEntities)) {
jpFactoryPackageService.saveBatch(packageEntities);
}
}
// 2 构建暂存单,发送 mq 消息
FactoryOrderLogEntity logEntity1 = new FactoryOrderLogEntity();
logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode());
logEntity1.setId(logId);
logService.saveOrUpdate(logEntity1);
// 处理暂存单
deliveryNoteService.buildFactoryAdvance(vo);
}
}
}

30
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryAuthVO.java

@ -0,0 +1,30 @@
package com.logpm.factorydata.paterson.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 物流商认证
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
public class FactoryAuthVO {
@ApiModelProperty(name = "物流编码")
private String logisticsCode;
@ApiModelProperty(name = "秘钥")
private String appKey;
@ApiModelProperty(name = "auth过期时间")
private Long authTime;
@ApiModelProperty(name = "物流公司")
private String companyCode;
@ApiModelProperty(name = "租户")
private String tenantCode;
@ApiModelProperty(name = "登录账号")
private String loginAccount;
@ApiModelProperty(name = "Authorization头")
private String authorizationHeader;
}

27
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderDataVO.java

@ -0,0 +1,27 @@
package com.logpm.factorydata.paterson.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 送货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "发货单", description = "发货单")
public class FactoryOrderDataVO {
@ApiModelProperty("加密后的密文")
private String digest;
@ApiModelProperty("时间戳 毫秒")
private Long timestamp;
@ApiModelProperty("公司编码")
private String companyCode;
@ApiModelProperty("订单信息")
private String params;
}

25
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryOrderVO.java

@ -0,0 +1,25 @@
package com.logpm.factorydata.paterson.vo;
import com.logpm.factorydata.paterson.entity.FactoryOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 送货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "发货单", description = "发货单")
@EqualsAndHashCode(callSuper = true)
public class FactoryOrderVO extends FactoryOrderEntity {
@ApiModelProperty(name = "包件明细")
private List<FactoryPackageVO> packageList;
}

21
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryPackageVO.java

@ -0,0 +1,21 @@
package com.logpm.factorydata.paterson.vo;
import com.logpm.factorydata.paterson.entity.FactoryPackageEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 送货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "发货单", description = "发货单")
@EqualsAndHashCode(callSuper = true)
public class FactoryPackageVO extends FactoryPackageEntity {
}

25
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/FactoryShipmentVO.java

@ -0,0 +1,25 @@
package com.logpm.factorydata.paterson.vo;
import com.logpm.factorydata.paterson.entity.FactoryShipmentEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 送货单 实体类
*
* @author zhaoqiaobo
* @create 2024-04-26
*/
@Data
@ApiModel(value = "发货单", description = "发货单")
@EqualsAndHashCode(callSuper = true)
public class FactoryShipmentVO extends FactoryShipmentEntity {
@ApiModelProperty(name = "订单明细")
private List<FactoryOrderVO> orderList;
}

26
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/PackageCategoryVO.java

@ -0,0 +1,26 @@
package com.logpm.factorydata.paterson.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqiaobo
* @create 2024-04-30
*/
@Data
public class PackageCategoryVO implements Serializable {
@ApiModelProperty(name = "一级品类")
private String typea;
@ApiModelProperty(name = "二级品类")
private String typeb;
@ApiModelProperty(name = "三级品类")
private String typec;
@ApiModelProperty(name = "包件码")
private String extBoxCode;
@ApiModelProperty(name = "包件类型")
private String extBoxType;
}

32
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/vo/ThirdPlWarehouseMappingVO.java

@ -0,0 +1,32 @@
package com.logpm.factorydata.paterson.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 百得胜三方物流仓库映射表
* @author zhaoqiaobo
* @create 2024-04-30
*/
@Data
public class ThirdPlWarehouseMappingVO implements Serializable {
/**
* 到站网点
*/
private String arriveOrgName;
/**
* 仓库id
*/
private String warehouseId;
/**
* 仓库名称
*/
private String warehouseName;
/**
* 租户id
*/
private String tenantId;
}

38
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/CustomHttpServletRequestWrapper.java

@ -0,0 +1,38 @@
package com.logpm.factorydata.paterson.wrapper;
import org.springframework.http.HttpHeaders;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper {
private final HttpHeaders headers;
public CustomHttpServletRequestWrapper(HttpServletRequest request) {
super(request);
headers = new HttpHeaders();
}
@Override
public String getHeader(String name) {
String headerValue = headers.getFirst(name);
return headerValue != null ? headerValue : super.getHeader(name);
}
@Override
public Enumeration<String> getHeaderNames() {
List<String> names = Collections.list(super.getHeaderNames());
headers.forEach((key, value) -> names.add(key));
return Collections.enumeration(names);
}
// 其他需要覆盖的方法...
public void addHeader(String name, String value) {
headers.add(name, value);
}
}

75
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/java/com/logpm/factorydata/paterson/wrapper/RequestWrapper.java

@ -0,0 +1,75 @@
package com.logpm.factorydata.paterson.wrapper;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class RequestWrapper extends HttpServletRequestWrapper {
private final String body;
public RequestWrapper(HttpServletRequest request) throws IOException {
super(request);
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = null;
try {
InputStream inputStream = request.getInputStream();
if (inputStream != null) {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
char[] charBuffer = new char[128];
int bytesRead = -1;
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
stringBuilder.append(charBuffer, 0, bytesRead);
}
} else {
stringBuilder.append("");
}
} catch (IOException ex) {
throw ex;
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException ex) {
throw ex;
}
}
}
body = stringBuilder.toString();
}
@Override
public ServletInputStream getInputStream() throws IOException {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
ServletInputStream servletInputStream = new ServletInputStream() {
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return false;
}
@Override
public void setReadListener(ReadListener readListener) {}
@Override
public int read() throws IOException {
return byteArrayInputStream.read();
}
};
return servletInputStream;
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(this.getInputStream()));
}
public String getBody() {
return this.body;
}
}

73
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-dev.yml

@ -0,0 +1,73 @@
#服务器端口
server:
port: 19010
#数据源配置
#spring:
# datasource:
# url: ${blade.datasource.dev.url}
# username: ${blade.datasource.dev.username}
# password: ${blade.datasource.dev.password}
spring:
#rabbitmq配置
rabbitmq:
host: 192.168.2.46
port: 5672
username: admin
password: admin
#虚拟host 可以不设置,使用server默认host
virtual-host: /
#确认消息已发送到队列(Queue)
publisher-returns: true
publisher-confirm-type: correlated
# 手动提交消息
listener:
simple:
acknowledge-mode: auto
default-requeue-rejected: false
retry:
enabled: true # 开启消费者失败重试
initial-interval: 1000 # 初识的失败等待时长为1秒
multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval
max-attempts: 3 # 最大重试次数
stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false
direct:
acknowledge-mode: manual
template:
mandatory: true
#排除DruidDataSourceAutoConfigure
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
dynamic:
druid:
#通用校验配置
validation-query: select 1
#启用sql日志拦截器
proxy-filters:
- sqlLogInterceptor
#设置默认的数据源或者数据源组,默认值即为master
primary: master
datasource:
master:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.master.url}
username: ${blade.datasource.factorydata-bds.master.username}
password: ${blade.datasource.factorydata-bds.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.627683.url}
username: ${blade.datasource.factorydata-bds.627683.username}
password: ${blade.datasource.factorydata-bds.627683.password}
blade:
data-scope:
enabled: false

47
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-prod.yml

@ -0,0 +1,47 @@
#服务器端口
server:
port: 19010
#数据源配置
#spring:
# datasource:
# url: ${blade.datasource.dev.url}
# username: ${blade.datasource.dev.username}
# password: ${blade.datasource.dev.password}
spring:
#排除DruidDataSourceAutoConfigure
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
dynamic:
druid:
#通用校验配置
validation-query: select 1
#启用sql日志拦截器
proxy-filters:
- sqlLogInterceptor
#设置默认的数据源或者数据源组,默认值即为master
primary: master
datasource:
master:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.master.url}
username: ${blade.datasource.factorydata-bds.master.username}
password: ${blade.datasource.factorydata-bds.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.627683.url}
username: ${blade.datasource.factorydata-bds.627683.username}
password: ${blade.datasource.factorydata-bds.627683.password}
blade:
data-scope:
enabled: false

73
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application-test.yml

@ -0,0 +1,73 @@
#服务器端口
server:
port: 19010
#数据源配置
#spring:
# datasource:
# url: ${blade.datasource.dev.url}
# username: ${blade.datasource.dev.username}
# password: ${blade.datasource.dev.password}
spring:
#rabbitmq配置
rabbitmq:
host: 192.168.2.110
port: 5672
username: admin
password: Slwk@123654
#虚拟host 可以不设置,使用server默认host
virtual-host: /
#确认消息已发送到队列(Queue)
publisher-returns: true
publisher-confirm-type: correlated
# 手动提交消息
listener:
simple:
acknowledge-mode: auto
default-requeue-rejected: false
retry:
enabled: true # 开启消费者失败重试
initial-interval: 1000 # 初识的失败等待时长为1秒
multiplier: 1 # 失败的等待时长倍数,下次等待时长 = multiplier * last-interval
max-attempts: 3 # 最大重试次数
stateless: true # true无状态;false有状态。如果业务中包含事务,这里改为false
direct:
acknowledge-mode: manual
template:
mandatory: true
#排除DruidDataSourceAutoConfigure
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
dynamic:
druid:
#通用校验配置
validation-query: select 1
#启用sql日志拦截器
proxy-filters:
- sqlLogInterceptor
#设置默认的数据源或者数据源组,默认值即为master
primary: master
datasource:
master:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.master.url}
username: ${blade.datasource.factorydata-bds.master.username}
password: ${blade.datasource.factorydata-bds.master.password}
627683:
druid:
#独立校验配置
validation-query: select 1
#oracle校验
#validation-query: select 1 from dual
url: ${blade.datasource.factorydata-bds.627683.url}
username: ${blade.datasource.factorydata-bds.627683.username}
password: ${blade.datasource.factorydata-bds.627683.password}
blade:
data-scope:
enabled: false

31
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/application.yml

@ -0,0 +1,31 @@
#mybatis-plus配置
mybatis-plus:
mapper-locations: classpath:com/logpm/**/mapper/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.logpm.**.entity
#swagger扫描路径配置
swagger:
base-packages:
- org.springblade
- com.logpm
#oss配置
oss:
enabled: true
name: minio
tenant-mode: false
endpoint: http://8.137.14.82:9000
access-key: minio
secret-key: 123123123
bucket-name: bladex
logging:
config: classpath:logback.xml
spring:
main:
allow-circular-references: true

40
blade-service/logpm-factory-data/logpm-factory-data-paterson/src/main/resources/logback.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="false" debug="false">
<contextName>logback</contextName>
<property name="log.path" value="./data/logpm-factory-data-suofeiya/logs/logs.log"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}.%d{yyyy-MM-dd}.zip</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n
</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="file"/>
</root>
</configuration>

49
blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/job/SpiderDataJob.java

@ -25,6 +25,7 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -62,6 +63,11 @@ public class SpiderDataJob {
@Autowired
private Executor asyncChangeDbExecutor;
@Autowired
private BladeRedis bladeRedis;
private LocalDate firstDayOfMonth;
private LocalDate lastDayOfMonth;
@ -79,6 +85,8 @@ public class SpiderDataJob {
startData =LocalDate.now().toString();
endData = LocalDate.now().minusDays(1).toString();
if(StringUtil.isNotBlank(param)){
if(param.contains(",")){
String[] split = param.split(",");
@ -91,6 +99,14 @@ public class SpiderDataJob {
}
// 获取当前日期的第一天 的日期 和最后一天的日期
LocalDate now = LocalDate.parse(startData);
firstDayOfMonth = now.withDayOfMonth(1);
lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth());
//
// startData ="2025-02-25";
@ -178,6 +194,7 @@ public class SpiderDataJob {
packageInfoEntity.setUpdateTime(new Date());
packageInfoEntity.setIsDeleted(0);
packageInfoEntity.setStatus(1);
packageInfoEntity.setDealerName(spiderInforEntity.getBindBussiness());
// 判断这个包条是否存在鱼数据库 如果不存在 则执行
@ -195,6 +212,7 @@ public class SpiderDataJob {
vo.setOrderInfo(orderInfo);
vo.setPackageInfo(packageInfoVOs);
}
log.debug(">>>>> vo {}",vo);
asyncChangeDbExecutor.execute(new ChdbTask(spiderInforEntity.getBindTenantCode(), vo,deliveryNoteService));
}
@ -308,14 +326,25 @@ public class SpiderDataJob {
JSONObject jsonObject = getData(url, buildCookies(username, password));
JSONArray temList = jsonObject.getJSONArray("result");
log.debug("getCarOrders 执行时间:{}",temList.size());
for (Object o : temList) {
JSONObject jsonObject1 = (JSONObject) o;
JSONObject list2 = getOrderInfor(jsonObject1.getStr("orderNumber"), username, password);
JSONArray list_2 = list2.getJSONArray("result");
for (Object o1 : list_2) {
JSONObject t = (JSONObject) o1;
result.add(t);
String orderNumber = jsonObject1.getStr("orderNumber");
String key = "sfy:factory:"+orderNumber+".lock";
Object o2 = bladeRedis.get(key);
if(o2 == null){
JSONObject list2 = getOrderInfor(orderNumber, username, password);
JSONArray list_2 = list2.getJSONArray("result");
for (Object o1 : list_2) {
JSONObject t = (JSONObject) o1;
result.add(t);
}
// 单号存储3个小时
bladeRedis.setEx(key,"1",60L);
}
}
@ -339,8 +368,14 @@ public class SpiderDataJob {
*/
private JSONObject getOrderInfor(String orderCode, String username, String password) {
Long _dc_ = System.currentTimeMillis();
String url ="https://portal.sfygroup.com/reporthome/rest/delivedryNotice/all?_dc="+_dc_+"&page=1&start=0&limit=20&filtersRaw=[{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+startData+"\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+endData+"\",\"operator\":\"<\",\"sql\":null},{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\""+orderCode+"\",\"operator\":\"like\",\"sql\":null}]";
String url ="https://portal.sfygroup.com/reporthome/rest/delivedryNotice/all?_dc="+_dc_
+"&page=1&start=0&limit=20&filtersRaw=[{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+
firstDayOfMonth+"\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\""+
lastDayOfMonth+"\",\"operator\":\"<\",\"sql\":null},{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\""+orderCode+"\",\"operator\":\"like\",\"sql\":null}]";
JSONObject jsonObject = getData(url, buildCookiesByDD(username, password));
return jsonObject;
@ -385,7 +420,7 @@ public class SpiderDataJob {
JSONArray response = new JSONArray();
//获取订单对应的装箱单
Long _dc_ = System.currentTimeMillis();
String url = "https://portal.sfygroup.com/reporthome/rest/orderPackHead/all?_dc=" + _dc_ + "&page=1&start=0&limit=1000&filtersRaw=[{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\"" + orderCode + "\",\"operator\":\"=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + startData + "\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + endData + "\",\"operator\":\"<\",\"sql\":null}]";
String url = "https://portal.sfygroup.com/reporthome/rest/orderPackHead/all?_dc=" + _dc_ + "&page=1&start=0&limit=1000&filtersRaw=[{\"id\":null,\"property\":\"A.ORDER_NUMBER\",\"value\":\"" + orderCode + "\",\"operator\":\"=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + firstDayOfMonth + "\",\"operator\":\">=\",\"sql\":null},{\"id\":null,\"property\":\"A.SCHEDULE_DELIVERY_DATE\",\"value\":\"" + lastDayOfMonth + "\",\"operator\":\"<\",\"sql\":null}]";
JSONObject data = getData(url, buildCookiesByZx(username, password));
JSONArray tempList = data.getJSONArray("result");
for (Object o : tempList) {

1
blade-service/logpm-factory-data/pom.xml

@ -22,6 +22,7 @@
<module>logpm-factory-data-mwh</module>
<module>logpm-factory-data-mengtian</module>
<module>logpm-factory-data-pan</module>
<module>logpm-factory-data-paterson</module>
</modules>
<properties>

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

@ -1093,12 +1093,14 @@ public class CarsLoadController {
// return R.fail(405,"未知的发车类型");
// }
carsLoadService.unloadByLoadId(loadCarsDTO);
try{
//同步一次系统无编码数据
carsLoadService.syncNoSystemData(loadId, myCurrentWarehouse.getId(), myCurrentWarehouse.getName());
carsLoadService.unloadByLoadId(loadCarsDTO);
carsLoadService.sendStationArrivedEnter(loadCarsDTO);
}catch (Exception e){

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

@ -93,7 +93,6 @@
<select id="selectInfoByIds" resultType="com.logpm.trunkline.vo.OpenOrderVO">
select GROUP_CONCAT(DISTINCT brand) brand,
GROUP_CONCAT(DISTINCT train_number) trainNumber,
GROUP_CONCAT(DISTINCT order_code) orderCode,
GROUP_CONCAT(DISTINCT dealer_code) dealerCode,
GROUP_CONCAT(DISTINCT dealer_name) dealerName
from logpm_trunkline_advance

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

@ -206,5 +206,5 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper<TrunklineCarsLoa
String findBrandNameByCarLoadCode(@Param("loadCode") String loadCode);
int findEntityByOrderPackageCodeAndUnloadTime(@Param("orderPackageCode") String orderPackageCode, @Param("unloadTime") Date unloadTime);
int findEntityByOrderPackageCodeAndUnloadTime(@Param("orderPackageCode") String orderPackageCode, @Param("unloadTime") Date unloadTime, @Param("warehouseId") Long warehouseId);
}

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

@ -1233,6 +1233,7 @@
from logpm_trunkline_cars_load_scan ltcls
where ltcls.scan_code = #{orderPackageCode}
and ltcls.unload_time > #{unloadTime}
and ltcls.unload_node_id != #{warehouseId}
</select>

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

@ -213,5 +213,5 @@ public interface ITrunklineCarsLoadScanService extends BaseService<TrunklineCars
*/
String findBrandNameByCarLoadCode(String loadCode);
int findEntityByOrderPackageCodeAndUnloadTime(String orderPackageCode, Date unloadTime);
int findEntityByOrderPackageCodeAndUnloadTime(String orderPackageCode, Date unloadTime, Long warehouseId);
}

19
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java

@ -18,6 +18,7 @@ import com.logpm.basic.entity.BasicCarModelEntity;
import com.logpm.basic.feign.IBasicCarModelClient;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.distribution.dto.FindParamterDTO;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.distribution.feign.IDistributionParcelListClient;
@ -548,6 +549,16 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService {
List<AftersalesAbnormalRecordEntity> addList = new ArrayList<>();
List<TrunklineCarsLoadScanEntity> noUnloadList = trunklineCarsLoadScanService.findUnloadCheckAbnormalNoUnloadList(loadId, warehouseId);
//把noUnloadList中所有元素的scanCode放入一个List
List<String> scanCodeList = noUnloadList.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toList());
FindParamterDTO findParamterDTO = new FindParamterDTO();
findParamterDTO.setOrderPackageCodeList(scanCodeList);
findParamterDTO.setWarehouseId(warehouseId);
List<DistributionParcelListEntity> parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO);
//把parcelListEntityList转化成以orderPackageCode作为key的Map
Map<String, DistributionParcelListEntity> parcelMap = parcelListEntityList.stream()
.collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity()));
for (TrunklineCarsLoadScanEntity trunklineCarsLoadScanEntity : noUnloadList) {
String loadCode = trunklineCarsLoadScanEntity.getLoadCode();
String waybillNo = trunklineCarsLoadScanEntity.getWaybillNo();
@ -579,6 +590,14 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService {
abnormalRecordEntity.setRemark("无卸车记录");
abnormalRecordEntity.setIsZero(0);
abnormalRecordEntity.setNum(1);
DistributionParcelListEntity distributionParcel = parcelMap.get(scanCode);
if(!Objects.isNull(distributionParcel)){
abnormalRecordEntity.setAbnormalStatus(1);
abnormalRecordEntity.setDealTime(new Date());
abnormalRecordEntity.setDealUserId(userId);
abnormalRecordEntity.setDealUserName(nickName);
abnormalRecordEntity.setRemark("无卸车记录,已在其他车次入库,系统判定自动完结");
}
addList.add(abnormalRecordEntity);
// abnormalRecordClient.addAbnormalRecord(abnormalRecordEntity);
}

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

@ -320,6 +320,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
String dealerName = null;
String dealerCode = null;
String brand = null;
Set<String> orderCodeSet = new HashSet<>();
for (TrunklineAdvanceEntity advanceEntity : list) {
if (StringUtil.isBlank(dealerName)) {
dealerName = advanceEntity.getDealerName();
@ -328,11 +329,13 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
if (StringUtil.isBlank(brand)) {
brand = advanceEntity.getBrand();
}
orderCodeSet.add(advanceEntity.getOrderCode());
}
OpenOrderVO openOrderVO = new OpenOrderVO();
//查询品牌 客户车次号 订单自编码
OpenOrderVO infoByIds = advanceService.selectInfoByIds(advanceIds);
BeanUtil.copy(infoByIds, openOrderVO);
openOrderVO.setOrderCode(String.join(",", orderCodeSet));
openOrderVO.setAdvanceIds(advanceIds);
BasicdataBrandEntity basicdataBrandEntity = basicdataBrandClient.findEntityByName(brand);
if (!Objects.isNull(basicdataBrandEntity)) {
@ -1818,6 +1821,12 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
dto.setOrderCode(dto.getOrderCode().trim());
dto.setOrderPackageCode(dto.getOrderPackageCode().trim());
});
List<BasicMaterialEntity> materialEntities = basicMaterialClient.findAllList();
//把materialEntities转化成以productCode和productName拼接为key的Map
Map<String, BasicMaterialEntity> materialEntityMap = materialEntities.stream().collect(Collectors.toMap(item -> item.getProductCode() + "&&" + item.getName(), item -> item));
//排除pacakgeDetailExcelDTOS中的orderPackageCode为空的元素
pacakgeDetailExcelDTOS = pacakgeDetailExcelDTOS.stream().filter(item -> StringUtil.isNotBlank(item.getOrderPackageCode())).collect(Collectors.toList());
//把importStandardOuPaiDTOS中orderPackageCode相同的元素去重
@ -2074,16 +2083,37 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
advanceDetailModel.setQuantity(1);
advanceDetailModel.setServiceNum(pacakgeDetailExcelDTO.getServiceNum());
advanceDetailModel.setPackageStatus("0");
String materialName = pacakgeDetailExcelDTO.getMaterialName();
String materialCode = pacakgeDetailExcelDTO.getMaterialCode();
advanceDetailModel.setMaterialName(materialName);
advanceDetailModel.setMaterialCode(materialCode);
if (!Objects.isNull(pacakgeDetailExcelDTO.getVolume())) {
advanceDetailModel.setVolume(new BigDecimal(pacakgeDetailExcelDTO.getVolume()));
} else {
advanceDetailModel.setVolume(BigDecimal.ZERO);
BasicMaterialEntity basicMaterialEntity = materialEntityMap.get(materialCode + "&&" + materialName);
if (!Objects.isNull(basicMaterialEntity)) {
advanceDetailModel.setMaterialId(basicMaterialEntity.getId());
String weight = basicMaterialEntity.getWeight();
if (StringUtil.isBlank(weight)) {
weight = "0";
}
String volume2 = basicMaterialEntity.getVolume();
if (StringUtil.isBlank(volume2)) {
volume2 = "0";
}
advanceDetailModel.setWeight(new BigDecimal(weight));
advanceDetailModel.setVolume(new BigDecimal(volume2));
}
}
String materialName = pacakgeDetailExcelDTO.getMaterialName();
String materialCode = pacakgeDetailExcelDTO.getMaterialCode();
advanceDetailModel.setMaterialName(materialName);
advanceDetailModel.setMaterialCode(materialCode);
// if (StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialName)) {
@ -4051,6 +4081,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
String dealerName = null;
String brand = null;
Integer totalNum = 0;
Set<String> orderCodeSet = new HashSet<>();
for (TrunklineAdvanceEntity advanceEntity : list) {
if (StringUtil.isBlank(dealerName)) {
dealerName = advanceEntity.getDealerName();
@ -4060,11 +4091,15 @@ public class OpenOrderServiceImpl implements IOpenOrderService {
}
totalNum = totalNum + advanceEntity.getTotalNum();
orderCodeSet.add(advanceEntity.getOrderCode());
}
OpenOrderVO openOrderVO = new OpenOrderVO();
//查询品牌 客户车次号 订单自编码
OpenOrderVO infoByIds = advanceService.selectInfoByIds(advanceIds);
BeanUtil.copy(infoByIds, openOrderVO);
openOrderVO.setOrderCode(String.join(",", orderCodeSet));
openOrderVO.setAdvanceIds(advanceIds);
//发站仓-----目前登录人的仓库
openOrderVO.setDepartureWarehouseName(basicdataWarehouseEntity.getName());

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

@ -39,8 +39,11 @@ 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.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Tenant;
import org.springblade.system.feign.ISysClient;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -65,6 +68,7 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
private final RabbitTemplate rabbitTemplate;
private final ITrunklineAdvanceDetailService advanceDetailService;
private final IBasicdataBrandClient basicdataBrandClient;
private final ISysClient sysClient;
@Override
public boolean saveOrderAndPackage(TrunklineAdvanceDetailEntity advanceDetailEntity, Long warehouseId) {
@ -764,7 +768,24 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
@Override
public boolean saveOrderAndPackages(List<TrunklineAdvanceDetailEntity> advanceDetailEntities, Long warehouseId) {
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
Integer isTransfer;
R<Tenant> tenant = sysClient.getTenant(AuthUtil.getTenantId());
if(tenant.isSuccess()){
Tenant data = tenant.getData();
if(new Integer(2).equals(data.getTenantType())){
isTransfer=0;
} else {
isTransfer = 1;
}
} else {
isTransfer = 1;
}
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if (Objects.isNull(warehouseEntity)) {
log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}", warehouseId);
throw new CustomerException(405, "仓库信息不存在");
@ -1010,7 +1031,11 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl<TrunklineAdvanc
parcelList.setTenantId(tenantId);
parcelList.setWarehouse(warehouseEntity.getName());
parcelList.setWarehouseId(warehouseId);
parcelList.setIsTransfer(1);
/*增加通过当前登陆人所应对的租户类型来判断是否是 中转包件 还是 目的仓包件*/
parcelList.setIsTransfer(isTransfer);
String waybillNo = ad.getWaybillNo();
if (StringUtil.isNotBlank(waybillNo)) {
WarehouseWaybillEntity waybillEntity = finalWaybillEntityMap.get(waybillNo);

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

@ -515,7 +515,7 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl<TrunklineC
}
@Override
public int findEntityByOrderPackageCodeAndUnloadTime(String orderPackageCode, Date unloadTime) {
return baseMapper.findEntityByOrderPackageCodeAndUnloadTime(orderPackageCode,unloadTime);
public int findEntityByOrderPackageCodeAndUnloadTime(String orderPackageCode, Date unloadTime, Long warehouseId) {
return baseMapper.findEntityByOrderPackageCodeAndUnloadTime(orderPackageCode,unloadTime,warehouseId);
}
}

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

@ -54,7 +54,6 @@ import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.springblade.common.annotations.RepeatSubmit;
import org.springblade.common.constant.*;
import org.springblade.common.constant.broadcast.FanoutConstants;
import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.exception.CustomerException;
@ -13542,6 +13541,16 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
List<String> scanCodeList = new ArrayList<>(scanCodeSet);
FindParamterDTO findParamterDTO = new FindParamterDTO();
findParamterDTO.setOrderPackageCodeList(scanCodeList);
findParamterDTO.setWarehouseId(warehouseId);
List<DistributionParcelListEntity> parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO);
//把parcelListEntityList转化成以orderPackageCode作为key的Map
Map<String, DistributionParcelListEntity> parcelMap = parcelListEntityList.stream()
.collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity()));
List<TrunklineAdvanceDetailEntity> allAdvanceDetailList = new ArrayList<>();
int packageBatchSize = 500;
@ -13609,7 +13618,13 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
updateScanEntity.setMaterialCode(trunklineAdvanceDetailEntity.getMaterialCode());
updateScanEntity.setMaterialName(trunklineAdvanceDetailEntity.getMaterialName());
updateScanEntity.setIsData(1);
updateScanList.add(updateScanEntity);
DistributionParcelListEntity parcelList = parcelMap.get(orderPackageCode);
if(Objects.isNull(parcelList)){
updateScanList.add(updateScanEntity);
}
}
});
@ -13642,7 +13657,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
orderPackageCodeList.add(orderPackageCode);
//查询是否有在系统无编码后进行卸车的数据
int unloadNum = trunklineCarsLoadScanService.findEntityByOrderPackageCodeAndUnloadTime(orderPackageCode,unloadTime);
int unloadNum = trunklineCarsLoadScanService.findEntityByOrderPackageCodeAndUnloadTime(orderPackageCode,unloadTime,warehouseId);
if(unloadNum > 0){
DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId);
if(!Objects.isNull(parcelListEntity)){
@ -13665,6 +13680,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
updateParceList.add(updateEntity);
});
}
TrunklineAdvanceDetailEntity updateEntity = new TrunklineAdvanceDetailEntity();
updateEntity.setId(trunklineAdvanceDetailEntity.getId());
updateEntity.setNowWarehouseId(warehouseId);
@ -13681,10 +13697,6 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
trunklineAdvanceDetailService.updateBatchById(updateNowWarehouseList);
}
if(CollUtil.isNotEmpty(updateScanList)){
trunklineCarsLoadScanService.updateBatchById(updateScanList);
}
// List<DistributionParcelListEntity> updateParceList = new ArrayList<>();
@ -13716,6 +13728,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
if(CollUtil.isNotEmpty(updateScanList)){
trunklineCarsLoadScanService.updateBatchById(updateScanList);
}
// trunklineCarsLoadScanService.updateBatchById(updateScanList);
//完结所有包件异常列表

Loading…
Cancel
Save