44 changed files with 1902 additions and 577 deletions
@ -0,0 +1,14 @@
|
||||
package org.springblade.common.annotations; |
||||
|
||||
import org.springframework.scheduling.annotation.Async; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD}) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface ChangeAsync { |
||||
String value() default ""; |
||||
} |
@ -0,0 +1,36 @@
|
||||
package org.springblade.common.component; |
||||
|
||||
import cn.hutool.http.HttpRequest; |
||||
import cn.hutool.http.HttpResponse; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.constant.LauncherConstant; |
||||
import org.springframework.core.env.Environment; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.Objects; |
||||
|
||||
@Component |
||||
@AllArgsConstructor |
||||
public class MockLoginService { |
||||
private final Environment environment; |
||||
public JSONObject mockToken(String tenantId,String account) { |
||||
String url = "http://" + LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0])) + "/blade-auth/oauth/token"; |
||||
HttpRequest urlRequest = HttpRequest.post(url); |
||||
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); |
||||
urlRequest.header("Tenant-Id", "627683"); |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("grant_type", "local_server"); |
||||
params.put("scope", "all"); |
||||
params.put("username", account); |
||||
params.put("tenantId", tenantId); |
||||
HttpResponse execute = urlRequest.form(params).execute(); |
||||
String body = execute.body(); |
||||
JSONObject jsonObject = JSONObject.parseObject(body); |
||||
return jsonObject; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<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> |
||||
|
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-business-conversion-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
<parent> |
||||
<groupId>org.springblade</groupId> |
||||
<version>3.2.0.RELEASE</version> |
||||
<artifactId>blade-service-api</artifactId> |
||||
</parent> |
||||
<properties> |
||||
<maven.compiler.source>8</maven.compiler.source> |
||||
<maven.compiler.target>8</maven.compiler.target> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
</properties> |
||||
|
||||
</project> |
@ -0,0 +1,12 @@
|
||||
package com.logpm.business.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class BusinessPreListDTO { |
||||
|
||||
private String reservationCode; |
||||
|
||||
private Integer inWarehouse; |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.logpm.business.dto; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
@Data |
||||
public class BusinessSanDTO { |
||||
String orderPackageCode; |
||||
String reservationCode; |
||||
|
||||
} |
@ -0,0 +1,266 @@
|
||||
/* |
||||
* 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.business.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 商场转换预处理 实体类 |
||||
* |
||||
* @author cyz |
||||
* @since 2023-06-13 |
||||
*/ |
||||
@Data |
||||
@TableName("logpm_business_pre_order") |
||||
@ApiModel(value = "DistributionBusinessPreOrder对象", description = "商场转换预处理实体") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class DistributionBusinessPreOrderEntity extends TenantEntity { |
||||
|
||||
/** |
||||
* 预留1 |
||||
*/ |
||||
@ApiModelProperty(value = "预留1") |
||||
private String reserve1; |
||||
/** |
||||
* 预留2 |
||||
*/ |
||||
@ApiModelProperty(value = "预留2") |
||||
private String reserve2; |
||||
/** |
||||
* 预留3 |
||||
*/ |
||||
@ApiModelProperty(value = "预留3") |
||||
private String reserve3; |
||||
/** |
||||
* 预留4 |
||||
*/ |
||||
@ApiModelProperty(value = "预留4") |
||||
private String reserve4; |
||||
/** |
||||
* 预留5 |
||||
*/ |
||||
@ApiModelProperty(value = "预留5") |
||||
private String reserve5; |
||||
/** |
||||
* 订单自编号 |
||||
*/ |
||||
@ApiModelProperty(value = "订单自编号") |
||||
private String orderCode; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 配送车牌 |
||||
*/ |
||||
@ApiModelProperty(value = "配送车牌") |
||||
private String vehicleName; |
||||
|
||||
|
||||
/** |
||||
* 配送司机 |
||||
*/ |
||||
@ApiModelProperty(value = "配送司机") |
||||
private String driverName; |
||||
|
||||
/** |
||||
* 仓库 |
||||
*/ |
||||
@ApiModelProperty(value = "仓库") |
||||
private String warehouse; |
||||
|
||||
@ApiModelProperty(value = "仓库ID") |
||||
private Long warehouseId; |
||||
/** |
||||
* 包件类型 1 定制品 2 库存品 3零担 |
||||
*/ |
||||
@ApiModelProperty(value = "状态") |
||||
private Integer conditions; |
||||
/** |
||||
* 包条码 |
||||
*/ |
||||
@ApiModelProperty(value = "包条码") |
||||
private String orderPackageCode; |
||||
|
||||
|
||||
/** |
||||
* 货位信息 |
||||
*/ |
||||
@ApiModelProperty(value = "货位信息") |
||||
private String goodsAllocation; |
||||
/** |
||||
* 所在托盘 |
||||
*/ |
||||
@ApiModelProperty(value = "所在托盘") |
||||
private String pallet; |
||||
/** |
||||
* 一级品 |
||||
*/ |
||||
@ApiModelProperty(value = "一级品") |
||||
private String firsts; |
||||
/** |
||||
* 二级品 |
||||
*/ |
||||
@ApiModelProperty(value = "二级品") |
||||
private String second; |
||||
/** |
||||
* 三级品 |
||||
*/ |
||||
@ApiModelProperty(value = "三级品") |
||||
private String thirdProduct; |
||||
/** |
||||
* 入库时间 |
||||
*/ |
||||
@ApiModelProperty(value = "入库时间") |
||||
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date warehouseEntryTimeEnd; |
||||
/** |
||||
* 运单号 |
||||
*/ |
||||
@ApiModelProperty(value = "运单号") |
||||
private String waybillNumber; |
||||
/** |
||||
* 运单ID |
||||
*/ |
||||
@ApiModelProperty(value = "运单ID") |
||||
private Long waybillId; |
||||
|
||||
/** |
||||
* 物料Id |
||||
*/ |
||||
@ApiModelProperty(value = "物料ID") |
||||
private Long materialId; |
||||
|
||||
/** |
||||
* 物料名称 |
||||
*/ |
||||
@ApiModelProperty(value = "物料名称") |
||||
private String materialName; |
||||
/** |
||||
* 物料编号 |
||||
*/ |
||||
@ApiModelProperty(value = "物料编号") |
||||
private String materialCode; |
||||
/** |
||||
* 物料单位 |
||||
*/ |
||||
@ApiModelProperty(value = "物料单位") |
||||
private String materialUnit; |
||||
/** |
||||
* 数量 |
||||
*/ |
||||
@ApiModelProperty(value = "数量") |
||||
private Integer quantity; |
||||
/** |
||||
* 车次号 |
||||
*/ |
||||
@ApiModelProperty(value = "车次号") |
||||
private String trainNumber; |
||||
/** |
||||
* 在库订单ID |
||||
*/ |
||||
@ApiModelProperty(value = "在库订单ID") |
||||
private Long stockArticleId; |
||||
|
||||
/** |
||||
* 服务号 |
||||
*/ |
||||
@ApiModelProperty(value = "服务号") |
||||
private String serviceNumber; |
||||
/** |
||||
* 品牌ID |
||||
*/ |
||||
@ApiModelProperty(value = "品牌ID") |
||||
private Long brandId; |
||||
/** |
||||
* 品牌名称 |
||||
*/ |
||||
@ApiModelProperty(value = "品牌名称") |
||||
private String brandName; |
||||
|
||||
/** |
||||
* 包件状态 |
||||
*/ |
||||
@ApiModelProperty(value = "包件状态") |
||||
private String orderPackageStatus; |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "经销商名称") |
||||
private String dealerName; |
||||
|
||||
@ApiModelProperty(value = "经销商编码") |
||||
private String dealerCode; |
||||
|
||||
@ApiModelProperty(value = "发站仓ID") |
||||
private Long sendWarehouseId; |
||||
|
||||
@ApiModelProperty(value = "发站仓ID") |
||||
private String sendWarehouseName; |
||||
|
||||
|
||||
@ApiModelProperty(value = "收站仓ID") |
||||
private Long acceptWarehouseId; |
||||
|
||||
@ApiModelProperty(value = "收站仓ID") |
||||
private String acceptWarehouseName; |
||||
|
||||
@ApiModelProperty(value = "装车状态") |
||||
private String orderPackageLoadingStatus; |
||||
|
||||
@ApiModelProperty(value = "重量") |
||||
private BigDecimal weight;//重量
|
||||
@ApiModelProperty(value = "体积") |
||||
private BigDecimal volume;//体积
|
||||
|
||||
@ApiModelProperty(value = "是否中转") |
||||
private Integer isTransfer;//是否中转
|
||||
|
||||
@ApiModelProperty(value = "暂存单id") |
||||
private Long advanceId;//暂存单id
|
||||
|
||||
@ApiModelProperty(value = "配送车次号") |
||||
private String distrCarNumber; |
||||
|
||||
@ApiModelProperty(value = "预约单号") |
||||
private String reservationCode; |
||||
|
||||
@ApiModelProperty(value = "是否入库 0 没有入库 1 已入库") |
||||
private Integer inWarehouse;//
|
||||
|
||||
@ApiModelProperty(value = "来源租户") |
||||
private String fromTenantId; |
||||
|
||||
|
||||
@ApiModelProperty(value = "操作状态 0 正常操作 1.补录操作") |
||||
private Integer operationStatus; |
||||
|
||||
// /**
|
||||
// * 配送状态
|
||||
// */
|
||||
// @ApiModelProperty(value = "配送状态")
|
||||
// private String orderPackageStatus;
|
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.logpm.business.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class DistributionBusinessPreOrderListVO implements Serializable { |
||||
|
||||
/** |
||||
* 总数 |
||||
*/ |
||||
private Integer sumNum; |
||||
|
||||
|
||||
/** |
||||
* 入库数量 |
||||
*/ |
||||
private Integer inNum; |
||||
|
||||
/** |
||||
* 列表数据 |
||||
*/ |
||||
private List<DistributionBusinessPreOrderVO> list; |
||||
|
||||
|
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.logpm.business.vo; |
||||
|
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Data |
||||
public class DistributionBusinessPreOrderVO extends DistributionBusinessPreOrderEntity { |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.logpm.distribution.appcontroller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.dto.BusinessSanDTO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderListVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.distribution.bean.Resp; |
||||
import com.logpm.distribution.service.IDistributionBusinessPreOrderService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/app/businessPreOrder") |
||||
@Api(value = "配送管理", tags = "配送管理App接口") |
||||
public class DistributionBusinessPreOrderAppController { |
||||
|
||||
private final IDistributionBusinessPreOrderService distributionBusinessPreOrderService; |
||||
|
||||
@ResponseBody |
||||
@PostMapping("/list") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "模糊查询", notes = "传入trayTypeDTO") |
||||
public R list(@RequestBody BusinessPreListDTO queryrderDTO){ |
||||
|
||||
DistributionBusinessPreOrderListVO data =distributionBusinessPreOrderService.list(queryrderDTO); |
||||
|
||||
return R.data(data); |
||||
} |
||||
|
||||
|
||||
@ResponseBody |
||||
@PostMapping("/scanOrderPackageCode") |
||||
@ApiOperationSupport(order = 1) |
||||
public Resp scanOrderPackageCode(@RequestBody BusinessSanDTO businessSanDTO){ |
||||
|
||||
Resp resp = null; |
||||
try { |
||||
resp = distributionBusinessPreOrderService.inOrderWarehourse(businessSanDTO.getOrderPackageCode(),businessSanDTO.getReservationCode()); |
||||
} catch (ExecutionException e) { |
||||
throw new RuntimeException(e); |
||||
} catch (InterruptedException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
|
||||
return resp; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,122 @@
|
||||
package com.logpm.distribution.aspect; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.aspectj.lang.ProceedingJoinPoint; |
||||
import org.aspectj.lang.annotation.Around; |
||||
import org.aspectj.lang.annotation.Aspect; |
||||
import org.aspectj.lang.reflect.MethodSignature; |
||||
import org.springblade.common.annotations.ChangeAsync; |
||||
import org.springblade.common.annotations.LogpmAsync; |
||||
import org.springblade.common.cache.CacheNames; |
||||
import org.springblade.common.component.MockLoginService; |
||||
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.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.core.tool.utils.ThreadLocalUtil; |
||||
import org.springframework.core.annotation.Order; |
||||
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.lang.reflect.Method; |
||||
import java.util.Objects; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Aspect |
||||
@Component |
||||
@Slf4j |
||||
@Order(-1) |
||||
@AllArgsConstructor |
||||
public class ChangeAsyncAnnotationAspect { |
||||
|
||||
private final MockLoginService mockLoginService; |
||||
|
||||
private final BladeRedis bladeRedis; |
||||
private final Environment environment; |
||||
private final RedisLockClient redisLockClient; |
||||
private final String account = "shujutongbu"; |
||||
|
||||
/** |
||||
* 定义一个切点,匹配所有带有@LogpmAsync("asyncExecutor")注解的方法。 |
||||
* 注意:实际上Spring Framework自带对@LogpmAsync("asyncExecutor")的处理,直接这样配置可能会导致预期之外的行为。 |
||||
*/ |
||||
@Around("@annotation(org.springblade.common.annotations.ChangeAsync)") |
||||
public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable { |
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
||||
Method method = signature.getMethod(); |
||||
|
||||
ChangeAsync myAsync = method.getAnnotation(ChangeAsync.class); |
||||
String annotationValue = myAsync.value(); |
||||
log.info(">>>>>>>>>>>>>>>>>> ChangeAsync={}", annotationValue); |
||||
|
||||
// 获取当前拦截方法的入参参数
|
||||
Object[] args = joinPoint.getArgs(); |
||||
// 获取入参名称
|
||||
String[] parameterNames = signature.getParameterNames(); |
||||
String tenantId = null; |
||||
// 获取参数名称 为tenantId 的值
|
||||
for (int i = 0; i < parameterNames.length; i++) { |
||||
if ("tenantId".equals(parameterNames[i])) { |
||||
tenantId = (String) args[i]; |
||||
log.info(">> tenandId {} ", tenantId); |
||||
break; |
||||
} |
||||
} |
||||
// 执行模拟登录
|
||||
if (StringUtil.isNotBlank(tenantId)) { |
||||
JSONObject data = bladeRedis.get(CacheNames.LOCAL_SERVER_USER + tenantId + ":" + account); |
||||
if (Objects.isNull(data)) { |
||||
boolean flag = redisLockClient.tryLock("local_server_user" + tenantId, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); |
||||
if (flag) { |
||||
data = bladeRedis.get(CacheNames.LOCAL_SERVER_USER + tenantId + ":" + account); |
||||
if (Objects.isNull(data)) { |
||||
data = mockLoginService.mockToken(tenantId, account); |
||||
bladeRedis.setEx(CacheNames.LOCAL_SERVER_USER + tenantId + ":" + account, data, 3200L); |
||||
redisLockClient.unLock("local_server_user" + tenantId, LockType.FAIR); |
||||
} |
||||
} |
||||
} |
||||
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest(); |
||||
mockRequest.addHeader("Blade-Auth", "bearer "+data.get("access_token")); |
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest)); |
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders(); |
||||
httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); |
||||
httpHeaders.add( "Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0"); |
||||
ThreadLocalUtil.put("bladeContext", httpHeaders); |
||||
|
||||
DynamicDataSourceContextHolder.push(data.getString("tenant_id")); |
||||
// 执行原方法
|
||||
Object result = joinPoint.proceed(); |
||||
// 在方法执行后,从数据源上下文中移除租户ID
|
||||
DynamicDataSourceContextHolder.poll(); |
||||
return result; |
||||
}else{ |
||||
return joinPoint.proceed(); |
||||
} |
||||
|
||||
|
||||
// // 在方法执行前的操作
|
||||
// String tenantId = AuthUtil.getTenantId();
|
||||
// log.info(">> tenandId {} ",tenantId);
|
||||
// DynamicDataSourceContextHolder.push("627683");
|
||||
//
|
||||
// // 执行原方法
|
||||
// Object result = joinPoint.proceed();
|
||||
//
|
||||
// // 在方法执行后的操作
|
||||
// DynamicDataSourceContextHolder.poll();
|
||||
// return result;
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,68 @@
|
||||
package com.logpm.distribution.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.distribution.entity.DistributionDeliveryListEntity; |
||||
import com.logpm.distribution.service.IDistributionBusinessPreOrderService; |
||||
import com.logpm.distribution.vo.DistributionDeliveryListVO; |
||||
import com.logpm.distribution.wrapper.DistributionDeliveryListWrapper; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
@RequestMapping("/businessPreOrder") |
||||
@Api(value = "配送增值服务明细", tags = "预入库信息控制器") |
||||
public class DistributionBusinessPreOrderController extends BladeController { |
||||
|
||||
private final IDistributionBusinessPreOrderService distributionBusinessPreOrderService; |
||||
|
||||
/** |
||||
* 预入库信息 分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入distributionDeliveryList") |
||||
public R<IPage<DistributionBusinessPreOrderVO>> list(@ApiIgnore @RequestParam Map<String, Object> distributionBusinessPreOrderDTO, Query query) { |
||||
IPage<DistributionBusinessPreOrderVO> page = Condition.getPage(query); |
||||
IPage<DistributionBusinessPreOrderVO> data= distributionBusinessPreOrderService.pacgeList(distributionBusinessPreOrderDTO,page); |
||||
return R.data(data); |
||||
} |
||||
|
||||
|
||||
@GetMapping("/inOrder") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "页面ID", notes = "传入distributionDeliveryList") |
||||
public R<Boolean> inOrder(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
// try {
|
||||
Boolean isSuccess =distributionBusinessPreOrderService.inOrder(ids); |
||||
return R.data(isSuccess); |
||||
// }catch (Exception e){
|
||||
// log.error("预入库信息入库失败",e);
|
||||
// return R.fail(500,e.getMessage());
|
||||
// }
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.logpm.distribution.dto; |
||||
|
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Data |
||||
public class DistributionBusinessPreOrderDTO extends DistributionBusinessPreOrderEntity { |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,62 @@
|
||||
/* |
||||
* 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.distribution.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.distribution.dto.DistributionBusinessPreOrderDTO; |
||||
import com.logpm.distribution.dto.DistributionParcelListDTO; |
||||
import com.logpm.distribution.dto.app.StockupDTO; |
||||
import com.logpm.distribution.entity.DistributionParcelListEntity; |
||||
import com.logpm.distribution.excel.DistributionParcelListExcel; |
||||
import com.logpm.distribution.vo.*; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* 商家预备导入数据信息 Mapper 接口 |
||||
* |
||||
* @author cyz |
||||
* @since 2023-06-13 |
||||
*/ |
||||
public interface DistributionBusinessPreOrderMapper extends BaseMapper<DistributionBusinessPreOrderEntity> { |
||||
|
||||
|
||||
/** |
||||
* 查询DistributionBusinessPreOrderVO列表 |
||||
* @param page |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
IPage<DistributionBusinessPreOrderVO> pageList(IPage<DistributionBusinessPreOrderVO> page, DistributionBusinessPreOrderDTO param); |
||||
|
||||
/** |
||||
* 删除商家端数据 |
||||
* @param k |
||||
* @param deletedPackageList |
||||
* @return |
||||
*/ |
||||
Integer deleteBusinessPreOrder(String reservationCode, List<String> deletedPackageList); |
||||
List<DistributionBusinessPreOrderEntity> listByBusinessPreListDTO(@Param("queryrderDTO") BusinessPreListDTO queryrderDTO); |
||||
} |
@ -0,0 +1,157 @@
|
||||
<?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.distribution.mapper.DistributionBusinessPreOrderMapper"> |
||||
<delete id="deleteBusinessPreOrder"> |
||||
DELETE FROM logpm_business_pre_order WHERE reservation_code = #{reservationCode} |
||||
AND order_package_code IN |
||||
<foreach |
||||
collection="orderPackageList" item="orderPackageCode" open="(" separator="," close=")"> |
||||
#{orderPackageCode} |
||||
</foreach> |
||||
</delete> |
||||
|
||||
|
||||
<select id="pageList" resultType="com.logpm.business.vo.DistributionBusinessPreOrderVO"> |
||||
SELECT |
||||
id, |
||||
firsts, |
||||
`SECOND`, |
||||
third_product, |
||||
quantity, |
||||
train_number, |
||||
order_code, |
||||
service_number, |
||||
material_name, |
||||
material_code, |
||||
brand_name, |
||||
waybill_number, |
||||
dealer_name, |
||||
dealer_code, |
||||
order_package_code, |
||||
reservation_code, |
||||
operation_status, |
||||
distr_car_number, |
||||
send_warehouse_name, |
||||
accept_warehouse_name, |
||||
weight, |
||||
volume, |
||||
driver_name, |
||||
vehicle_name, |
||||
distr_car_number, |
||||
in_warehouse |
||||
FROM |
||||
logpm_business_pre_order |
||||
<where> |
||||
is_deleted = 0 |
||||
<if test="param.id != null and param.id != ''"> |
||||
AND id = #{param.id} |
||||
</if> |
||||
<!-- <if test="param.ids != null ">--> |
||||
<!-- AND id IN--> |
||||
<!-- <foreach collection="param.ids" item="item" index="index" open="(" close=")" separator=",">--> |
||||
<!-- #{otem}--> |
||||
<!-- </foreach>--> |
||||
<!-- </if>--> |
||||
<if test="param.firsts != null and param.firsts != ''"> |
||||
AND firsts like concat(#{param.id},'%') |
||||
</if> |
||||
|
||||
<if test="param.second != null and param.second != ''"> |
||||
AND `SECOND` like concat(#{param.second},'%') |
||||
</if> |
||||
<if test="param.thirdProduct != null and param.thirdProduct != ''"> |
||||
AND third_product like concat(#{param.thirdProduct},'%') |
||||
</if> |
||||
<if test="param.trainNumber != null and param.trainNumber != ''"> |
||||
AND train_number like concat(#{param.trainNumber},'%') |
||||
</if> |
||||
<if test="param.orderCode != null and param.orderCode != ''"> |
||||
AND order_code like concat(#{param.orderCode},'%') |
||||
</if> |
||||
<if test="param.serviceNumber != null and param.serviceNumber != ''"> |
||||
AND service_number like concat(#{param.serviceNumber},'%') |
||||
</if> |
||||
<if test="param.materialName != null and param.materialName != ''"> |
||||
AND material_name like concat(#{param.materialName},'%') |
||||
</if> |
||||
<if test="param.materialCode != null and param.materialCode != ''"> |
||||
AND material_code like concat(#{param.materialCode},'%') |
||||
</if> |
||||
<if test="param.brandName != null and param.brandName != ''"> |
||||
AND brand_name like concat(#{param.brandName},'%') |
||||
</if> |
||||
<if test="param.waybillNumber != null and param.waybillNumber != ''"> |
||||
AND waybill_number like concat(#{param.waybillNumber},'%') |
||||
</if> |
||||
<if test="param.dealerName != null and param.dealerName != ''"> |
||||
AND dealer_name like concat(#{param.dealerName},'%') |
||||
</if> |
||||
<if test="param.dealerCode != null and param.dealerCode != ''"> |
||||
AND dealer_code like concat(#{param.dealerCode},'%') |
||||
</if> |
||||
<if test="param.sendWarehouseName != null and param.sendWarehouseName != ''"> |
||||
AND send_warehouse_name like concat(#{param.sendWarehouseName},'%') |
||||
</if> |
||||
<if test="param.acceptWarehouseName != null and param.acceptWarehouseName != ''"> |
||||
AND accept_warehouse_name like concat(#{param.acceptWarehouseName},'%') |
||||
</if> |
||||
<if test="param.driverName != null and param.driverName != ''"> |
||||
AND driver_name like concat(#{param.driverName},'%') |
||||
</if> |
||||
<if test="param.vehicleName != null and param.vehicleName != ''"> |
||||
AND vehicle_name like concat(#{param.vehicleName},'%') |
||||
</if> |
||||
<if test="param.distrCarNumber != null and param.distrCarNumber != ''"> |
||||
AND distr_car_number like concat(#{param.distrCarNumber},'%') |
||||
</if> |
||||
<if test="param.inWarehouse != null and param.inWarehouse != ''"> |
||||
AND in_warehouse = #{param.inWarehouse} |
||||
</if> |
||||
</where> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</select> |
||||
<select id="listByBusinessPreListDTO" resultType="com.logpm.business.entity.DistributionBusinessPreOrderEntity"> |
||||
|
||||
SELECT |
||||
id, |
||||
firsts, |
||||
`SECOND`, |
||||
third_product, |
||||
quantity, |
||||
train_number, |
||||
order_code, |
||||
order_package_code, |
||||
service_number, |
||||
material_name, |
||||
material_code, |
||||
brand_name, |
||||
waybill_number, |
||||
dealer_name, |
||||
dealer_code, |
||||
send_warehouse_name, |
||||
accept_warehouse_name, |
||||
weight, |
||||
volume, |
||||
driver_name, |
||||
vehicle_name, |
||||
distr_car_number, |
||||
in_warehouse |
||||
FROM |
||||
logpm_business_pre_order |
||||
<where> |
||||
is_deleted = 0 |
||||
<if test="queryrderDTO.reservationCode != null and queryrderDTO.reservationCode != ''"> |
||||
AND reservation_code = #{queryrderDTO.reservationCode} |
||||
</if> |
||||
</where> |
||||
|
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,245 @@
|
||||
package com.logpm.distribution.receiver; |
||||
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.distribution.entity.DistributionDeliveryListEntity; |
||||
import com.logpm.distribution.entity.DistributionParcelListEntity; |
||||
import com.logpm.distribution.entity.DistributionReservationEntity; |
||||
import com.logpm.distribution.entity.DistributionReservationPackageEntity; |
||||
import com.logpm.distribution.service.*; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.RabbitConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.ObjectUtil; |
||||
import org.springblade.system.entity.Tenant; |
||||
import org.springblade.system.feign.ISysClient; |
||||
import org.springframework.amqp.core.Message; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.function.Function; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Slf4j |
||||
@RabbitListener(queues = RabbitConstant.BUSINESS_PRE_CONVERSION_DATA_QUEUE) |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class BusinessPreOrderDataQueueHandler { |
||||
|
||||
private final IDistributionDeliveryListService distributionDeliveryListService; |
||||
private final IDistributionReservationService distributionReservationService; |
||||
private final IDistributionReservationPackageService distributionReservationPackageService; |
||||
private final IDistributionParcelListService distributionParcelListService; |
||||
private final IDistributionBusinessPreOrderService distributionBusinessPreOrderService; |
||||
private final ISysClient sysClient; |
||||
|
||||
@RabbitHandler |
||||
public void businessPreOrderDataHandler(Map map, Message message, Channel channel) { |
||||
|
||||
|
||||
String mallName = "仁寿欧派大家居"; |
||||
|
||||
Long t = (Long) map.get("messageData"); |
||||
if (ObjectUtil.isEmpty(t)) { |
||||
log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 配送ID为空"); |
||||
return; |
||||
} |
||||
|
||||
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListService.getById(t); |
||||
if (ObjectUtil.isEmpty(distributionDeliveryListEntity)) { |
||||
log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 配送对象为null"); |
||||
return; |
||||
} |
||||
|
||||
List<DistributionReservationEntity> list = distributionReservationService.selectListByDeliveryId(distributionDeliveryListEntity.getId()); |
||||
|
||||
if (ObjectUtil.isEmpty(list)) { |
||||
log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 预约列表为空"); |
||||
return; |
||||
} |
||||
|
||||
List<DistributionBusinessPreOrderEntity> dataResult = new ArrayList<>(); |
||||
for (DistributionReservationEntity distributionReservationEntity : list) { |
||||
// 判断需要进行推送商家名称
|
||||
log.info(">>>>> mallName TAG {}", mallName); |
||||
log.info(">>>>> distributionReservationEntity.getMallName() TAG {}", distributionReservationEntity.getMallName()); |
||||
if (mallName.equals(distributionReservationEntity.getMallName())) { |
||||
// 将当前的预约单加入到需要推送的列表
|
||||
LambdaQueryWrapper<DistributionReservationPackageEntity> queryWrapper = new LambdaQueryWrapper<>(); |
||||
queryWrapper.eq(DistributionReservationPackageEntity::getReservationId, distributionReservationEntity.getId()); |
||||
queryWrapper.ne(DistributionReservationPackageEntity::getPacketBarStatus, 2); |
||||
List<DistributionReservationPackageEntity> distributionReservationPackageEntityList = distributionReservationPackageService.list(queryWrapper); |
||||
|
||||
for (DistributionReservationPackageEntity distributionReservationPackageEntity : distributionReservationPackageEntityList) { |
||||
|
||||
|
||||
DistributionParcelListEntity byId = distributionParcelListService.getById(distributionReservationPackageEntity.getParceListId()); |
||||
DistributionBusinessPreOrderEntity data = BeanUtil.copy(byId, DistributionBusinessPreOrderEntity.class); |
||||
|
||||
data.setDriverName(distributionDeliveryListEntity.getDriverName()); |
||||
data.setVehicleName(distributionDeliveryListEntity.getVehicleName()); |
||||
data.setDistrCarNumber(distributionDeliveryListEntity.getTrainNumber()); |
||||
data.setFromTenantId(byId.getTenantId()); |
||||
data.setOperationStatus(0); |
||||
data.setInWarehouse(0); |
||||
data.setId(null); |
||||
data.setTenantId(null); |
||||
data.setReservationCode(distributionReservationEntity.getReservationCode()); |
||||
dataResult.add(data); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
// 查询包间列表
|
||||
|
||||
saveOtherDataBaseNew(dataResult, mallName); |
||||
// 查询配送单对应的司机
|
||||
|
||||
// 需要将查询出来的数据与 当前保存的数据进行比对 避免重复插入
|
||||
|
||||
// 通过商场名称找到租户中存在的商场名称
|
||||
|
||||
// 切换当前线程的数据源 插入到 租户对应的数据库中
|
||||
|
||||
log.info("businessPreOrderDataHandler:{}", map); |
||||
} |
||||
|
||||
public void saveOtherDataBaseNew(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) { |
||||
|
||||
// 查询保存的对象在商场端是否存在 && 没有入库的 都i需要删除 执行新的
|
||||
List<Long> orderIdList = dataResult.stream() |
||||
.map(DistributionBusinessPreOrderEntity::getStockArticleId) |
||||
.collect(Collectors.toList()); |
||||
R<Tenant> tenantByName = sysClient.getTenantByName(maillName); |
||||
if (tenantByName.isSuccess()) { |
||||
Tenant tenant = tenantByName.getData(); |
||||
if (ObjectUtil.isEmpty(tenant)) { |
||||
log.info(">>>>>>>>>>>>> saveOtherDataBaseNew 租户不存在"); |
||||
return; |
||||
} |
||||
if (dataResult.isEmpty()) { |
||||
log.info(" saveOtherDataBaseNew dataResult 参数错误"); |
||||
} |
||||
DynamicDataSourceContextHolder.push(tenant.getTenantId()); |
||||
|
||||
LambdaQueryWrapper<DistributionBusinessPreOrderEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
||||
lambdaQueryWrapper.eq(DistributionBusinessPreOrderEntity::getInWarehouse, 0); |
||||
lambdaQueryWrapper.in(DistributionBusinessPreOrderEntity::getStockArticleId, orderIdList); |
||||
List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(lambdaQueryWrapper); |
||||
|
||||
|
||||
// 找到已经推送的包件信息 并将其标记为删除状态
|
||||
List<Long> temsp = new ArrayList<>(); |
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : list) { |
||||
|
||||
for (DistributionBusinessPreOrderEntity businessPreOrderEntity : dataResult) { |
||||
businessPreOrderEntity.setTenantId(tenant.getTenantId()); |
||||
|
||||
|
||||
if (businessPreOrderEntity.getStockArticleId().equals(distributionBusinessPreOrderEntity.getStockArticleId())) { |
||||
// 找到订单
|
||||
|
||||
if (businessPreOrderEntity.getOrderPackageCode().equals(distributionBusinessPreOrderEntity.getOrderPackageCode())) { |
||||
//找到包件 并标记为删除状态
|
||||
temsp.add(distributionBusinessPreOrderEntity.getId()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
if (!temsp.isEmpty()) { |
||||
// 更新删除状态
|
||||
distributionBusinessPreOrderService.deleteLogic(temsp); |
||||
} |
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : dataResult) { |
||||
distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId()); |
||||
} |
||||
|
||||
// 执行保存操作
|
||||
distributionBusinessPreOrderService.saveBatch(dataResult); |
||||
DynamicDataSourceContextHolder.poll(); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
// public void saveOtherDataBase(List<DistributionBusinessPreOrderEntity> dataResult, String maillName) {
|
||||
// String method = "########################saveOtherDataBase";
|
||||
// R<Tenant> tenantByName = sysClient.getTenantByName(maillName);
|
||||
// if (tenantByName.isSuccess()) {
|
||||
// Tenant tenant = tenantByName.getData();
|
||||
// if (ObjectUtil.isEmpty(tenant)) {
|
||||
// log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 租户不存在");
|
||||
// return;
|
||||
// }
|
||||
// if (dataResult.isEmpty()) {
|
||||
// log.info(method + "dataResult 参数错误");
|
||||
// }
|
||||
// DynamicDataSourceContextHolder.push(tenant.getTenantId());
|
||||
// Map<Integer, List<DistributionBusinessPreOrderEntity>> map = dataResult.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse));
|
||||
// if (Func.isNotEmpty(map.get(1))) {
|
||||
// //存在需要进行删除的数据
|
||||
// List<DistributionBusinessPreOrderEntity> deleteList = map.get(0);
|
||||
// if (!deleteList.isEmpty()) {
|
||||
// Map<String, List<DistributionBusinessPreOrderEntity>> deletedMap = deleteList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
|
||||
// deletedMap.forEach((k, v) -> {
|
||||
// List<String> deletedPackageList = v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList());
|
||||
// log.info("删除商家端数据>>>>reservationCode:{}", deletedPackageList);
|
||||
// if (!deletedPackageList.isEmpty()) {
|
||||
// //进行删除
|
||||
// Integer row = distributionBusinessPreOrderService.deleteBusinessPreOrder(k, deletedPackageList);
|
||||
// log.info("删除商家端数据>>>>row:{}", row);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// if (Func.isNotEmpty(map.get(0))) {
|
||||
// //存在可能变更的数据
|
||||
// List<DistributionBusinessPreOrderEntity> mapList = map.get(0);
|
||||
// Map<String, List<DistributionBusinessPreOrderEntity>> saveData = mapList.stream().collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getReservationCode));
|
||||
// List<DistributionBusinessPreOrderEntity> existData = new ArrayList<>();
|
||||
// if (!saveData.isEmpty()) {
|
||||
// //查询是否存在重复
|
||||
// saveData.forEach((k, v) -> {
|
||||
// List<DistributionBusinessPreOrderEntity> list = distributionBusinessPreOrderService.list(Wrappers.<DistributionBusinessPreOrderEntity>query().lambda()
|
||||
// .eq(DistributionBusinessPreOrderEntity::getReservationCode, k)
|
||||
// .in(DistributionBusinessPreOrderEntity::getOrderPackageCode, v.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()))
|
||||
// );
|
||||
// if (!list.isEmpty()) {
|
||||
// //已经存在数据
|
||||
// existData.addAll(list);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// if (!existData.isEmpty()) {
|
||||
// //二者比较取差集
|
||||
// mapList = mapList.stream().filter(m -> !existData.stream().map(DistributionBusinessPreOrderEntity::getOrderPackageCode).collect(Collectors.toList()).contains(m.getOrderPackageCode())).collect(Collectors.toList());
|
||||
// }
|
||||
// if (!mapList.isEmpty()) {
|
||||
// for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : mapList) {
|
||||
// distributionBusinessPreOrderEntity.setTenantId(tenant.getTenantId());
|
||||
// }
|
||||
// distributionBusinessPreOrderService.saveBatch(mapList);
|
||||
// }
|
||||
// }
|
||||
// DynamicDataSourceContextHolder.poll();
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.logpm.distribution.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderListVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.distribution.bean.Resp; |
||||
import com.logpm.distribution.entity.DistributionBillLadingScanEntity; |
||||
import org.springblade.common.exception.CustomerException; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.core.mp.support.Query; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
public interface IDistributionBusinessPreOrderService extends BaseService<DistributionBusinessPreOrderEntity> { |
||||
/** |
||||
* 预备入库ID集合 |
||||
* @param ids |
||||
* @return |
||||
*/ |
||||
Boolean inOrder(String ids) throws ServiceException; |
||||
|
||||
|
||||
/** |
||||
* 查询DistributionBusinessPreOrder列表 |
||||
* @param distributionBusinessPreOrderDTO |
||||
* @param page |
||||
* @return |
||||
*/ |
||||
IPage<DistributionBusinessPreOrderVO> pacgeList(Map<String, Object> distributionBusinessPreOrderDTO, IPage<DistributionBusinessPreOrderVO> page); |
||||
|
||||
/** |
||||
* 删除商家端数据 |
||||
* @param k |
||||
* @param deletedPackageList |
||||
* @return |
||||
*/ |
||||
Integer deleteBusinessPreOrder(String k, List<String> deletedPackageList); |
||||
DistributionBusinessPreOrderListVO list(BusinessPreListDTO queryrderDTO); |
||||
|
||||
Resp inOrderWarehourse(String orderPackageCode,String reservationCode) throws ExecutionException, InterruptedException; |
||||
} |
@ -0,0 +1,272 @@
|
||||
package com.logpm.distribution.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
||||
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
||||
import com.logpm.basicdata.feign.IBasicdataClientClient; |
||||
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderListVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.distribution.bean.Resp; |
||||
import com.logpm.distribution.dto.DistributionBusinessPreOrderDTO; |
||||
import com.logpm.distribution.dto.DistributionStockArticleOweDTO; |
||||
import com.logpm.distribution.entity.DistributionParcelListEntity; |
||||
import com.logpm.distribution.entity.DistributionStockArticleEntity; |
||||
import com.logpm.distribution.mapper.DistributionBusinessPreOrderMapper; |
||||
import com.logpm.distribution.service.IDistributionAsyncService; |
||||
import com.logpm.distribution.service.IDistributionBusinessPreOrderService; |
||||
import com.logpm.distribution.service.IDistributionParcelListService; |
||||
import com.logpm.distribution.service.IDistributionStockArticleService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.annotations.ChangeAsync; |
||||
import org.springblade.common.annotations.LogpmAsync; |
||||
import org.springblade.common.exception.CustomerException; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springframework.scheduling.annotation.Async; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.concurrent.CompletableFuture; |
||||
import java.util.concurrent.ExecutionException; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Service |
||||
@AllArgsConstructor |
||||
public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<DistributionBusinessPreOrderMapper, DistributionBusinessPreOrderEntity> implements IDistributionBusinessPreOrderService { |
||||
|
||||
private final IDistributionStockArticleService distributionStockArticleService; |
||||
|
||||
private final IBasicdataWarehouseClient basicdataWarehouseClient; |
||||
private final IDistributionParcelListService distributionParcelListService; |
||||
private final IDistributionAsyncService distributionAsyncService; |
||||
|
||||
@Override |
||||
public Boolean inOrder(String ids) throws ServiceException { |
||||
|
||||
// 查询出来需要处理的包条码
|
||||
List<String> idArray = Arrays.asList(ids.split(",")); |
||||
QueryWrapper wrapper = new QueryWrapper(); |
||||
wrapper.in("id", idArray); |
||||
List<DistributionBusinessPreOrderEntity> list = baseMapper.selectList(wrapper); |
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : list) { |
||||
|
||||
if (distributionBusinessPreOrderEntity.getInWarehouse() == 1) { |
||||
throw new ServiceException("存在已入库的包件"); |
||||
} |
||||
//调用方法 执行批量入库
|
||||
DistributionStockArticleEntity stockArticleEntity = buildDistributionStockArticleEntity(distributionBusinessPreOrderEntity); |
||||
if (stockArticleEntity == null) { |
||||
throw new ServiceException("订单信息错误,请联系管理员!"); |
||||
} |
||||
// 保存包件
|
||||
distributionBusinessPreOrderEntity.setWarehouseId(stockArticleEntity.getWarehouseId()); |
||||
distributionBusinessPreOrderEntity.setWarehouse(stockArticleEntity.getWarehouse()); |
||||
distributionBusinessPreOrderEntity.setStockArticleId(stockArticleEntity.getId()); |
||||
buildDistributionParcelListEntity(distributionBusinessPreOrderEntity); |
||||
|
||||
// 调用入库方法
|
||||
distributionBusinessPreOrderEntity.setInWarehouse(1); |
||||
baseMapper.updateById(distributionBusinessPreOrderEntity); |
||||
|
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public IPage<DistributionBusinessPreOrderVO> pacgeList(Map<String, Object> distributionBusinessPreOrderDTO, IPage<DistributionBusinessPreOrderVO> page) { |
||||
DistributionBusinessPreOrderDTO param = JSONObject.parseObject(JSONObject.toJSONString(distributionBusinessPreOrderDTO), DistributionBusinessPreOrderDTO.class); |
||||
return baseMapper.pageList(page, param); |
||||
} |
||||
|
||||
@Override |
||||
public Integer deleteBusinessPreOrder(String k, List<String> deletedPackageList) { |
||||
|
||||
return baseMapper.deleteBusinessPreOrder(k, deletedPackageList); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public DistributionBusinessPreOrderListVO list(BusinessPreListDTO queryrderDTO) { |
||||
|
||||
DistributionBusinessPreOrderListVO distributionBusinessPreOrderListVO = new DistributionBusinessPreOrderListVO(); |
||||
|
||||
|
||||
List<DistributionBusinessPreOrderEntity> data = baseMapper.listByBusinessPreListDTO(queryrderDTO); |
||||
|
||||
|
||||
// data 分组
|
||||
Map<Integer, List<DistributionBusinessPreOrderEntity>> groupedData = data.stream() |
||||
.collect(Collectors.groupingBy(DistributionBusinessPreOrderEntity::getInWarehouse)); |
||||
|
||||
// 已入库的
|
||||
List<DistributionBusinessPreOrderEntity> distributionBusinessPreOrderEntities = groupedData.get(1); |
||||
|
||||
|
||||
List<DistributionBusinessPreOrderVO> result = new ArrayList<>(); |
||||
for (DistributionBusinessPreOrderEntity datum : data) { |
||||
|
||||
if(datum.getInWarehouse() .equals(queryrderDTO.getInWarehouse()) ){ |
||||
DistributionBusinessPreOrderVO copy = BeanUtil.copy(datum, DistributionBusinessPreOrderVO.class); |
||||
result.add(copy); |
||||
} |
||||
|
||||
} |
||||
distributionBusinessPreOrderListVO.setList(result); |
||||
distributionBusinessPreOrderListVO.setSumNum(data.size()); |
||||
distributionBusinessPreOrderListVO.setInNum(ObjectUtils.isEmpty(distributionBusinessPreOrderEntities) ? 0 : distributionBusinessPreOrderEntities.size()); |
||||
|
||||
|
||||
return distributionBusinessPreOrderListVO; |
||||
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Resp inOrderWarehourse(String orderPackageCode, String reservationCode) { |
||||
|
||||
|
||||
// 查询当前预约单所有的包件
|
||||
|
||||
LambdaQueryWrapper<DistributionBusinessPreOrderEntity> queryWrapper = new LambdaQueryWrapper<>(); |
||||
queryWrapper.eq(DistributionBusinessPreOrderEntity::getReservationCode, reservationCode); |
||||
List<DistributionBusinessPreOrderEntity> list = baseMapper.selectList(queryWrapper); |
||||
|
||||
// 寻找 当前匹配的包条
|
||||
DistributionBusinessPreOrderEntity t = null; |
||||
DistributionBusinessPreOrderEntity t1 = null; |
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : list) { |
||||
if (distributionBusinessPreOrderEntity.getOrderPackageCode().equals(orderPackageCode)) { |
||||
// 找到匹配的包条码
|
||||
if (distributionBusinessPreOrderEntity.getInWarehouse() == 1) { |
||||
return Resp.scanSuccess("扫描成功", "包件已入库"); |
||||
} else { |
||||
t = distributionBusinessPreOrderEntity; |
||||
} |
||||
} |
||||
if (t1 == null) { |
||||
t1 = distributionBusinessPreOrderEntity; |
||||
} |
||||
} |
||||
if (t == null) { |
||||
try { |
||||
DistributionBusinessPreOrderEntity finalT = t1; |
||||
CompletableFuture<DistributionParcelListEntity> distributionParcelListEntityCompletableFuture = CompletableFuture.supplyAsync(() -> this.selectByOrderPackageCode(orderPackageCode, finalT.getAcceptWarehouseId())); |
||||
|
||||
DistributionParcelListEntity distributionParcelListEntity = distributionParcelListEntityCompletableFuture.get(); |
||||
|
||||
// 如找到了 保存在当前的这个配送计划任务中
|
||||
if (distributionParcelListEntity != null) { |
||||
// 保存包件
|
||||
t = BeanUtil.copy(distributionParcelListEntity, DistributionBusinessPreOrderEntity.class); |
||||
t.setDriverName(finalT.getDriverName()); |
||||
t.setVehicleName(finalT.getVehicleName()); |
||||
t.setDistrCarNumber(finalT.getTrainNumber()); |
||||
t.setOperationStatus(1); |
||||
t.setInWarehouse(0); |
||||
this.save(t); |
||||
list.add(t); |
||||
|
||||
} |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
log.error("inOrderWarehourse:", e); |
||||
throw new ServiceException("包件信息不存在!"); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
// 保存订单
|
||||
DistributionStockArticleEntity stockArticleEntity = buildDistributionStockArticleEntity(t); |
||||
if (stockArticleEntity == null) { |
||||
return Resp.scanFail("操作失败", "包件数据不存在"); |
||||
} |
||||
// 保存包件
|
||||
t.setWarehouseId(stockArticleEntity.getWarehouseId()); |
||||
t.setWarehouse(stockArticleEntity.getWarehouse()); |
||||
t.setStockArticleId(stockArticleEntity.getId()); |
||||
buildDistributionParcelListEntity(t); |
||||
|
||||
// 调用入库方法
|
||||
t.setInWarehouse(1); |
||||
baseMapper.updateById(t); |
||||
|
||||
// 没有找到对应的包间 是否需要去 业务系统中获取
|
||||
queryWrapper.eq(DistributionBusinessPreOrderEntity::getInWarehouse, 1); |
||||
Long l = baseMapper.selectCount(queryWrapper); |
||||
|
||||
return Resp.scanSuccess("扫描成功", l + "件"); |
||||
} |
||||
|
||||
private void buildDistributionParcelListEntity(DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity) { |
||||
DistributionParcelListEntity distributionParcelListEntity = BeanUtil.copy(distributionBusinessPreOrderEntity, DistributionParcelListEntity.class); |
||||
distributionParcelListEntity.setId(null); |
||||
|
||||
distributionParcelListEntity.setOrderPackageFreezeStatus("10"); |
||||
distributionParcelListEntity.setOrderPackageStatus("20"); |
||||
distributionParcelListEntity.setOrderPackageLoadingStatus("10"); |
||||
distributionParcelListEntity.setOrderPackageReservationStatus("10"); |
||||
distributionParcelListEntity.setOrderPackageGroundingStatus("10"); |
||||
distributionParcelListEntity.setOrderPackageStockupStatus("10"); |
||||
|
||||
|
||||
distributionParcelListService.save(distributionParcelListEntity); |
||||
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(distributionParcelListEntity.getStockArticleId()); |
||||
//增加
|
||||
// 统计订单下的包间总数
|
||||
|
||||
LambdaQueryWrapper<DistributionParcelListEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
||||
lambdaQueryWrapper.eq(DistributionParcelListEntity::getStockArticleId, distributionParcelListEntity.getStockArticleId()); |
||||
long count = distributionParcelListService.count(lambdaQueryWrapper); |
||||
stockArticleEntity.setHandQuantity((int) count); |
||||
distributionStockArticleService.updateById(stockArticleEntity); |
||||
|
||||
} |
||||
|
||||
private DistributionStockArticleEntity buildDistributionStockArticleEntity(DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity) { |
||||
DistributionStockArticleEntity stockArticleEntity = null; |
||||
try { |
||||
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
||||
stockArticleEntity = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(distributionBusinessPreOrderEntity.getOrderCode(), |
||||
myCurrentWarehouse.getId()); |
||||
if (stockArticleEntity == null) { |
||||
// 需要保存这个对象
|
||||
CompletableFuture<DistributionStockArticleEntity> distributionStockArticleEntityCompletableFuture = CompletableFuture.supplyAsync(() -> distributionAsyncService.findDistributionStockArticleEntityByIdForAsync(distributionBusinessPreOrderEntity.getFromTenantId(), distributionBusinessPreOrderEntity.getStockArticleId())); |
||||
stockArticleEntity = distributionStockArticleEntityCompletableFuture.get(); |
||||
if (stockArticleEntity == null) { |
||||
return null; |
||||
} |
||||
// 获取当前登录人的仓库信息
|
||||
stockArticleEntity.setId(null); |
||||
stockArticleEntity.setTenantId(null); |
||||
stockArticleEntity.setWarehouseId(myCurrentWarehouse.getId()); |
||||
stockArticleEntity.setWarehouse(myCurrentWarehouse.getName()); |
||||
stockArticleEntity.setHandQuantity(0); |
||||
distributionStockArticleService.save(stockArticleEntity); |
||||
} |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
log.error("buildDistributionStockArticleEntity :", e); |
||||
throw new CustomerException("系统异常,请联系管理员"); |
||||
} |
||||
return stockArticleEntity; |
||||
} |
||||
|
||||
@ChangeAsync() |
||||
public DistributionParcelListEntity selectByOrderPackageCode(String orderPackageCode, Long warehouseId) { |
||||
|
||||
return distributionParcelListService.selectByOrderPackageCode(orderPackageCode, warehouseId); |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue