67 changed files with 3153 additions and 892 deletions
@ -0,0 +1,18 @@
|
||||
<?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> |
||||
|
||||
<parent> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-service-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
</parent> |
||||
|
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-business-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,13 @@
|
||||
package com.logpm.business.dto; |
||||
|
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class DistributionBusinessPreOrderDTO extends DistributionBusinessPreOrderEntity { |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.logpm.business.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class DistributionBusinessPreCarNumberVO { |
||||
|
||||
@ApiModelProperty(value = "配送车次") |
||||
private String distrCarNumber; |
||||
|
||||
@ApiModelProperty(value = "运单号") |
||||
private String waybillNumber; |
||||
|
||||
@ApiModelProperty(value = "订单号") |
||||
private String orderCode; |
||||
|
||||
|
||||
@ApiModelProperty(value = "总件数") |
||||
private Integer totalNum; |
||||
|
||||
@ApiModelProperty(value = "入库件数") |
||||
private Integer inNum; |
||||
|
||||
@ApiModelProperty(value = "待入库件数") |
||||
private Integer restNum; |
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.logpm.distribution.feign; |
||||
|
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
@FeignClient( |
||||
value = ModuleNameConstant.APPLICATION_DISTRIBUTION_NAME |
||||
) |
||||
public interface IDistributionBusinessPreOrderClient { |
||||
|
||||
|
||||
String API_PREFIX = "/client"; |
||||
String INORDERBYORDERPACKAGECODE = API_PREFIX + "/inOrderByOrderPackageCode"; |
||||
@GetMapping(INORDERBYORDERPACKAGECODE) |
||||
public Integer inOrderByOrderPackageCode(@RequestParam("orderPackageCode") String orderPackageCode, @RequestParam("carNum")String carNum); |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.logpm.trunkline.feign; |
||||
|
||||
import com.logpm.trunkline.dto.InComingDTO; |
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
||||
@FeignClient( |
||||
value = ModuleNameConstant.APPLICATION_TRUNKLINE_NAME |
||||
) |
||||
public interface IInComingClient { |
||||
|
||||
String API_PREFIX = "inComing/client"; |
||||
|
||||
|
||||
@PostMapping(API_PREFIX+"/incomingPackage") |
||||
R incomingPackage(@RequestBody InComingDTO inComingDTO); |
||||
|
||||
} |
@ -0,0 +1,118 @@
|
||||
<?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> |
||||
|
||||
<parent> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-service</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
</parent> |
||||
|
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-business</artifactId> |
||||
<name>${project.artifactId}</name> |
||||
<version>${bladex.project.version}</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-boot</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-swagger</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-excel</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-auto</artifactId> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-amqp</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-business-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-business-conversion-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-trunkline-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-basicdata-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-distribution-api</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-warehouse-api</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-user-api</artifactId> |
||||
<version>${bladex.project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-system-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> |
@ -0,0 +1,17 @@
|
||||
package com.logpm.business; |
||||
|
||||
|
||||
import org.springblade.common.constant.ModuleNameConstant; |
||||
import org.springblade.core.cloud.client.BladeCloudApplication; |
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springblade.core.transaction.annotation.SeataCloudApplication; |
||||
|
||||
@BladeCloudApplication |
||||
@SeataCloudApplication |
||||
public class BusinessApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
BladeApplication.run(ModuleNameConstant.LOGPM_BUSINESS_NAME, BusinessApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.logpm.business.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.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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,120 @@
|
||||
package com.logpm.business.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.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.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,48 @@
|
||||
package com.logpm.business.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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.logpm.business.bean; |
||||
|
||||
import lombok.Data; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
@Data |
||||
public class Resp extends R { |
||||
|
||||
private String audio; |
||||
|
||||
public static Resp scanSuccess(String msg,String audio){ |
||||
Resp resp = new Resp(); |
||||
resp.setCode(200); |
||||
resp.setMsg(msg); |
||||
resp.setAudio(audio); |
||||
return resp; |
||||
} |
||||
|
||||
public static Resp scanFail(String msg,String audio){ |
||||
Resp resp = new Resp(); |
||||
resp.setCode(3001); |
||||
resp.setMsg(msg); |
||||
resp.setAudio(audio); |
||||
return resp; |
||||
} |
||||
|
||||
public static Resp scanFail(int code,String msg,String audio){ |
||||
Resp resp = new Resp(); |
||||
resp.setCode(code); |
||||
resp.setMsg(msg); |
||||
resp.setAudio(audio); |
||||
return resp; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* 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.config; |
||||
|
||||
|
||||
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; |
||||
|
||||
/** |
||||
* 配置feign、mybatis包名、properties |
||||
* |
||||
* @author chaos |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ComponentScan({"org.springblade", "com.logpm"}) |
||||
@EnableFeignClients({"org.springblade", "com.logpm"}) |
||||
@MapperScan({"org.springblade.**.mapper.**", "com.logpm.**.mapper.**"}) |
||||
@EnableConfigurationProperties(BusinessProperties.class) |
||||
public class BusinessProperties { |
||||
|
||||
} |
@ -0,0 +1,79 @@
|
||||
package com.logpm.business.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.logpm.business.service.IDistributionBusinessPreOrderService; |
||||
import com.logpm.business.vo.DistributionBusinessPreCarNumberVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
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>> page(@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("/pageByCarNum") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入distributionDeliveryList") |
||||
public R<IPage<DistributionBusinessPreCarNumberVO>> pageByCarNum(@ApiIgnore @RequestParam Map<String, Object> distributionBusinessPreOrderDTO, Query query) { |
||||
IPage<DistributionBusinessPreCarNumberVO> page = Condition.getPage(query); |
||||
IPage<DistributionBusinessPreCarNumberVO> data= distributionBusinessPreOrderService.pageByCarNum(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,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.business.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 BusinessLauncherServiceImpl 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; |
||||
} |
||||
} |
@ -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.business.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.dto.DistributionBusinessPreOrderDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreCarNumberVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 商家预备导入数据信息 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, @Param("param") DistributionBusinessPreOrderDTO param); |
||||
|
||||
/** |
||||
* 删除商家端数据 |
||||
* |
||||
* @param deletedPackageList |
||||
* @return |
||||
*/ |
||||
Integer deleteBusinessPreOrder(String reservationCode, List<String> deletedPackageList); |
||||
|
||||
List<DistributionBusinessPreOrderEntity> listByBusinessPreListDTO(@Param("queryrderDTO") BusinessPreListDTO queryrderDTO); |
||||
|
||||
Integer updateBusinessPreOrderByOrderPackageCode(@Param("orderPackageCode") String orderPackageCode); |
||||
|
||||
IPage<DistributionBusinessPreCarNumberVO> pageByCarNum(IPage<DistributionBusinessPreCarNumberVO> page, Map<String, Object> distributionBusinessPreOrderDTO); |
||||
} |
@ -0,0 +1,187 @@
|
||||
<?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.business.mapper.DistributionBusinessPreOrderMapper"> |
||||
<update id="updateBusinessPreOrderByOrderPackageCode"> |
||||
|
||||
|
||||
update logpm_business_pre_order set in_warehouse=1 |
||||
|
||||
where order_package_code=#{orderPackageCode} and is_deleted=0 and in_warehouse=0 |
||||
|
||||
</update> |
||||
<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, |
||||
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.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 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> |
||||
<select id="pageByCarNum" resultType="com.logpm.business.vo.DistributionBusinessPreCarNumberVO"> |
||||
|
||||
SELECT distr_car_number, |
||||
waybill_number, |
||||
order_code, |
||||
COUNT(1) as totalNum, |
||||
COUNT(CASE WHEN in_warehouse = 1 THEN 1 END) as inNum, |
||||
COUNT(1)-COUNT(CASE WHEN in_warehouse = 1 THEN 1 END) as restNum |
||||
from logpm_business_pre_order |
||||
|
||||
<where> |
||||
is_deleted=0 |
||||
<if test="distributionBusinessPreOrderDTO.distrCarNumber != null and distributionBusinessPreOrderDTO.distrCarNumber != ''"> |
||||
AND distr_car_number = #{distributionBusinessPreOrderDTO.distrCarNumber} |
||||
</if> |
||||
<if test="distributionBusinessPreOrderDTO.waybillNumber != null and distributionBusinessPreOrderDTO.waybillNumber != ''"> |
||||
and waybill_number=#{distributionBusinessPreOrderDTO.waybillNumber} |
||||
</if> |
||||
<if test="distributionBusinessPreOrderDTO.orderCode != null and distributionBusinessPreOrderDTO.orderCode != ''"> |
||||
and order_code LIKE CONCAT(#{distributionBusinessPreOrderDTO.orderCode},'%') |
||||
</if> |
||||
|
||||
</where> |
||||
GROUP BY |
||||
distr_car_number, |
||||
waybill_number, |
||||
order_code |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,31 @@
|
||||
package com.logpm.business.receiver; |
||||
|
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.RabbitConstant; |
||||
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.Map; |
||||
|
||||
/** |
||||
* 商家完结订单 |
||||
*/ |
||||
@Slf4j |
||||
@RabbitListener(queues = RabbitConstant.BUSINESS_IN_CONVERSION_DATA_QUEUE) |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class BusinessInOrderDataQueueHandler { |
||||
|
||||
@RabbitHandler |
||||
public void businessInOrderDataHandler(Map map, Message message, Channel channel) { |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.logpm.business.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.business.bean.Resp; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.vo.DistributionBusinessPreCarNumberVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderListVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
|
||||
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; |
||||
|
||||
|
||||
/** |
||||
* 更新预入库状态 |
||||
* @param orderPackageCode 包条码 |
||||
* @param carNum 入库的配送车次 |
||||
* @return |
||||
*/ |
||||
Integer inOrderByOrderPackageCode(String orderPackageCode,String carNum); |
||||
|
||||
/** |
||||
* 查询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; |
||||
|
||||
IPage<DistributionBusinessPreCarNumberVO> pageByCarNum(Map<String, Object> distributionBusinessPreOrderDTO, IPage<DistributionBusinessPreCarNumberVO> page); |
||||
|
||||
} |
@ -0,0 +1,249 @@
|
||||
package com.logpm.business.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
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.IBasicdataWarehouseClient; |
||||
import com.logpm.business.bean.Resp; |
||||
import com.logpm.business.dto.BusinessPreListDTO; |
||||
import com.logpm.business.dto.DistributionBusinessPreOrderDTO; |
||||
import com.logpm.business.entity.DistributionBusinessPreOrderEntity; |
||||
import com.logpm.business.mapper.DistributionBusinessPreOrderMapper; |
||||
import com.logpm.business.service.IDistributionBusinessPreOrderService; |
||||
import com.logpm.business.vo.DistributionBusinessPreCarNumberVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderListVO; |
||||
import com.logpm.business.vo.DistributionBusinessPreOrderVO; |
||||
import com.logpm.trunkline.dto.InComingDTO; |
||||
import com.logpm.trunkline.feign.IInComingClient; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.constant.IncomingTypeEnum; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Service |
||||
@AllArgsConstructor |
||||
public class IDistributionBusinessPreOrderServiceImpl extends BaseServiceImpl<DistributionBusinessPreOrderMapper, DistributionBusinessPreOrderEntity> implements IDistributionBusinessPreOrderService { |
||||
|
||||
|
||||
private final IBasicdataWarehouseClient basicdataWarehouseClient; |
||||
|
||||
private final IInComingClient inComingClient; |
||||
|
||||
@Override |
||||
public Boolean inOrder(String ids) throws ServiceException { |
||||
|
||||
// 查询出来需要处理的包条码
|
||||
List<String> idArray = Arrays.asList(ids.split(",")); |
||||
QueryWrapper wrapper = new QueryWrapper(); |
||||
wrapper.in("id", idArray); |
||||
|
||||
InComingDTO inComingDTO = new InComingDTO(); |
||||
StringBuffer sb = new StringBuffer(); |
||||
List<DistributionBusinessPreOrderEntity> list = baseMapper.selectList(wrapper); |
||||
|
||||
List<DistributionBusinessPreOrderEntity> data = new ArrayList<>(); |
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : list) { |
||||
|
||||
if (distributionBusinessPreOrderEntity.getInWarehouse() == 1) { |
||||
throw new ServiceException("存在已入库的包件"); |
||||
} |
||||
if(!sb.toString().isEmpty()){ |
||||
sb.append(","); |
||||
} |
||||
sb.append(distributionBusinessPreOrderEntity.getOrderPackageCode()); |
||||
data.add(distributionBusinessPreOrderEntity); |
||||
} |
||||
|
||||
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
||||
inComingDTO.setOrderPackageCode(sb.toString()); |
||||
inComingDTO.setIncomingType(IncomingTypeEnum.LINE_INCOMING.getCode()); |
||||
inComingDTO.setWarehouseId(myCurrentWarehouse.getId()); |
||||
inComingDTO.setWarehouseName(myCurrentWarehouse.getName()); |
||||
R r = inComingClient.incomingPackage(inComingDTO); |
||||
if(r.isSuccess()){ |
||||
// 更新成功
|
||||
for (DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity : data) { |
||||
distributionBusinessPreOrderEntity.setInWarehouse(1); |
||||
baseMapper.updateById(distributionBusinessPreOrderEntity); |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
|
||||
|
||||
@Override |
||||
public Integer inOrderByOrderPackageCode(String orderPackageCode,String carNum) { |
||||
|
||||
|
||||
QueryWrapper wrapper = new QueryWrapper(); |
||||
wrapper.eq("order_package_code", orderPackageCode); |
||||
// wrapper.eq("in_warehouse",0);
|
||||
wrapper.eq("is_deleted","0"); |
||||
List<DistributionBusinessPreOrderEntity> list = baseMapper.selectList(wrapper); |
||||
if(!list.isEmpty()){ |
||||
DistributionBusinessPreOrderEntity distributionBusinessPreOrderEntity = list.get(0); |
||||
|
||||
distributionBusinessPreOrderEntity.setInWarehouse(1); |
||||
return baseMapper.updateById(distributionBusinessPreOrderEntity); |
||||
} |
||||
return 0; |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
@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("扫描成功", "请前往码板打托进行入库!"); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public IPage<DistributionBusinessPreCarNumberVO> pageByCarNum(Map<String, Object> distributionBusinessPreOrderDTO, IPage<DistributionBusinessPreCarNumberVO> page) { |
||||
|
||||
IPage<DistributionBusinessPreCarNumberVO> pageByCarNum =baseMapper.pageByCarNum(page, distributionBusinessPreOrderDTO); |
||||
|
||||
return pageByCarNum; |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,53 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 17020 |
||||
|
||||
#数据源配置 |
||||
#spring: |
||||
# datasource: |
||||
# url: ${blade.datasource.dev.url} |
||||
# username: ${blade.datasource.dev.username} |
||||
# password: ${blade.datasource.dev.password} |
||||
|
||||
spring: |
||||
autoconfigure: |
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||
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.business.master.url} |
||||
username: ${blade.datasource.business.master.username} |
||||
password: ${blade.datasource.business.master.password} |
||||
627683: |
||||
druid: |
||||
#独立校验配置 |
||||
validation-query: select 1 |
||||
#oracle校验 |
||||
#validation-query: select 1 from dual |
||||
url: ${blade.datasource.business.627683.url} |
||||
username: ${blade.datasource.business.627683.username} |
||||
password: ${blade.datasource.business.627683.password} |
||||
703623: |
||||
druid: |
||||
#独立校验配置 |
||||
validation-query: select 1 |
||||
#oracle校验 |
||||
#validation-query: select 1 from dual |
||||
url: ${blade.datasource.business.703623.url} |
||||
username: ${blade.datasource.business.703623.username} |
||||
password: ${blade.datasource.business.703623.password} |
||||
|
@ -0,0 +1,68 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 17020 |
||||
|
||||
#数据源配置 |
||||
#spring: |
||||
# datasource: |
||||
# url: ${blade.datasource.prod.url} |
||||
# username: ${blade.datasource.prod.username} |
||||
# password: ${blade.datasource.prod.password} |
||||
|
||||
spring: |
||||
#排除DruidDataSourceAutoConfigure |
||||
autoconfigure: |
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||
datasource: |
||||
dynamic: |
||||
druid: |
||||
proxy-filters: |
||||
- sqlLogInterceptor |
||||
#设置默认的数据源或者数据源组,默认值即为master |
||||
primary: master |
||||
datasource: |
||||
master: |
||||
url: ${blade.datasource.warehouse.master.url} |
||||
username: ${blade.datasource.warehouse.master.username} |
||||
password: ${blade.datasource.warehouse.master.password} |
||||
627683: |
||||
url: ${blade.datasource.warehouse.627683.url} |
||||
username: ${blade.datasource.warehouse.627683.username} |
||||
password: ${blade.datasource.warehouse.627683.password} |
||||
#rabbitmq配置 |
||||
rabbitmq: |
||||
host: 172.16.128.145 |
||||
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 |
||||
xxl: |
||||
job: |
||||
accessToken: '' |
||||
admin: |
||||
addresses: http://172.16.128.147:7009/xxl-job-admin |
||||
executor: |
||||
appname: logpm-factory-xxljob |
||||
ip: 127.0.0.1 |
||||
logpath: ../data/applogs/logpm-factory-xxljob/jobhandler |
||||
logretentiondays: -1 |
||||
port: 7018 |
@ -0,0 +1,68 @@
|
||||
#服务器端口 |
||||
server: |
||||
port: 17020 |
||||
|
||||
#数据源配置 |
||||
#spring: |
||||
# datasource: |
||||
# url: ${blade.datasource.test.url} |
||||
# username: ${blade.datasource.test.username} |
||||
# password: ${blade.datasource.test.password} |
||||
|
||||
spring: |
||||
#排除DruidDataSourceAutoConfigure |
||||
autoconfigure: |
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure,com.alibaba.cloud.seata.feign.SeataFeignClientAutoConfiguration |
||||
datasource: |
||||
dynamic: |
||||
druid: |
||||
proxy-filters: |
||||
- sqlLogInterceptor |
||||
#设置默认的数据源或者数据源组,默认值即为master |
||||
primary: master |
||||
datasource: |
||||
master: |
||||
url: ${blade.datasource.warehouse.master.url} |
||||
username: ${blade.datasource.warehouse.master.username} |
||||
password: ${blade.datasource.warehouse.master.password} |
||||
627683: |
||||
url: ${blade.datasource.warehouse.627683.url} |
||||
username: ${blade.datasource.warehouse.627683.username} |
||||
password: ${blade.datasource.warehouse.627683.password} |
||||
#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 |
||||
xxl: |
||||
job: |
||||
accessToken: '' |
||||
admin: |
||||
addresses: http://127.0.0.1:7009/xxl-job-admin |
||||
executor: |
||||
appname: logpm-factory-xxljob |
||||
ip: 127.0.0.1 |
||||
logpath: ../data/applogs/logpm-factory-xxljob/jobhandler |
||||
logretentiondays: -1 |
||||
port: 7018 |
@ -0,0 +1,24 @@
|
||||
#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 |
||||
|
||||
|
||||
logging: |
||||
config: classpath:logback.xml |
||||
|
||||
|
||||
spring: |
||||
main: |
||||
allow-circular-references: true |
||||
|
||||
|
||||
|
||||
|
@ -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-warehouse/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> |
@ -1,36 +1,36 @@
|
||||
package com.logpm.distribution.config; |
||||
|
||||
import org.redisson.Redisson; |
||||
import org.redisson.config.Config; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.tool.utils.SpringUtil; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Configuration |
||||
public class RedissonConfig { |
||||
|
||||
@Bean |
||||
public Redisson redisson() { |
||||
// 单机模式
|
||||
Config config = new Config(); |
||||
|
||||
BladeRedis bean = SpringUtil.getBean(BladeRedis.class); |
||||
|
||||
RedisConnectionFactory connectionFactory = bean.getRedisTemplate().getConnectionFactory(); |
||||
|
||||
LettuceConnectionFactory factory = (LettuceConnectionFactory) connectionFactory; |
||||
|
||||
String hostName = factory.getHostName(); |
||||
int port = factory.getPort(); |
||||
String password = factory.getPassword(); |
||||
|
||||
config.useSingleServer().setAddress("redis://"+hostName+":"+port).setDatabase(1); |
||||
config.useSingleServer().setPassword(password); |
||||
return (Redisson) Redisson.create(config); |
||||
} |
||||
|
||||
} |
||||
//package com.logpm.distribution.config;
|
||||
//
|
||||
//import org.redisson.Redisson;
|
||||
//import org.redisson.config.Config;
|
||||
//import org.springblade.core.redis.cache.BladeRedis;
|
||||
//import org.springblade.core.tool.utils.SpringUtil;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Configuration
|
||||
//public class RedissonConfig {
|
||||
//
|
||||
// @Bean
|
||||
// public Redisson redisson() {
|
||||
// // 单机模式
|
||||
// Config config = new Config();
|
||||
//
|
||||
// BladeRedis bean = SpringUtil.getBean(BladeRedis.class);
|
||||
//
|
||||
// RedisConnectionFactory connectionFactory = bean.getRedisTemplate().getConnectionFactory();
|
||||
//
|
||||
// LettuceConnectionFactory factory = (LettuceConnectionFactory) connectionFactory;
|
||||
//
|
||||
// String hostName = factory.getHostName();
|
||||
// int port = factory.getPort();
|
||||
// String password = factory.getPassword();
|
||||
//
|
||||
// config.useSingleServer().setAddress("redis://"+hostName+":"+port).setDatabase(1);
|
||||
// config.useSingleServer().setPassword(password);
|
||||
// return (Redisson) Redisson.create(config);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.logpm.distribution.feign; |
||||
|
||||
import com.logpm.distribution.service.IDistributionBusinessPreOrderService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
@ApiIgnore() |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class DistributionBusinessPreOrderClient implements IDistributionBusinessPreOrderClient { |
||||
private final IDistributionBusinessPreOrderService distributionBusinessPreOrderService; |
||||
@Override |
||||
public Integer inOrderByOrderPackageCode(String orderPackageCode, String carNum) { |
||||
return distributionBusinessPreOrderService.inOrderByOrderPackageCode(orderPackageCode,carNum); |
||||
} |
||||
} |
@ -0,0 +1,120 @@
|
||||
package com.logpm.trunkline.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.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.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,22 @@
|
||||
package com.logpm.trunkline.feign; |
||||
|
||||
import com.logpm.trunkline.dto.InComingDTO; |
||||
import com.logpm.trunkline.service.IInComingService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
@Slf4j |
||||
@ApiIgnore() |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class InComingClient implements IInComingClient{ |
||||
private final IInComingService inComingService; |
||||
@Override |
||||
public R incomingPackage(InComingDTO inComingDTO) { |
||||
|
||||
return inComingService.incomingPackage(inComingDTO); |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
package com.logpm.trunkline.mq; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.logpm.distribution.feign.IDistributionBusinessPreOrderClient; |
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.RabbitConstant; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.messaging.Message; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 码半 |
||||
* 入库扫描 |
||||
* 触发商家的入库数据 |
||||
*/ |
||||
|
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Component |
||||
@RabbitListener(queues = RabbitConstant.IN_WAREHOUSE_TO_BUSINESS_DATA_QUEUE) |
||||
public class InWarehourseToBusinessListener { |
||||
|
||||
private final IDistributionBusinessPreOrderClient distributionBusinessPreOrderClient; |
||||
@RabbitHandler |
||||
public void inWarehourseToBusinessDataHandler(Map map, Message message, Channel channel) { |
||||
|
||||
extracted(map); |
||||
|
||||
|
||||
} |
||||
|
||||
private void extracted(Map map) { |
||||
log.info("入库扫描-触发商家的入库数据-入参:{}", map); |
||||
|
||||
JSONObject o = (JSONObject) map.get("messageData"); |
||||
|
||||
String orderPackageCode = o.getString("orderPackageCode"); |
||||
String carNum = o.getString("carNum"); |
||||
if(carNum==null){ |
||||
carNum=""; |
||||
} |
||||
|
||||
Integer i = distributionBusinessPreOrderClient.inOrderByOrderPackageCode(orderPackageCode, carNum); |
||||
log.info(">>>>>>>>>>>>>>>>>> 入库操作 执行 {}",i); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,148 @@
|
||||
package com.logpm.trunkline.mq; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.logpm.distribution.entity.DistributionParcelListEntity; |
||||
import com.logpm.trunkline.entity.TrunklineAdvanceEntity; |
||||
import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; |
||||
import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity; |
||||
import com.logpm.trunkline.entity.TrunklineWaybillTrackEntity; |
||||
import com.logpm.trunkline.feign.ITrunklineAdvanceClient; |
||||
import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient; |
||||
import com.logpm.trunkline.feign.ITrunklineWaybillOrderClient; |
||||
import com.logpm.trunkline.feign.ITrunklineWaybillPackageClient; |
||||
import com.logpm.trunkline.service.IAsyncService; |
||||
import com.logpm.trunkline.service.ITrunklineWaybillTrackService; |
||||
import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; |
||||
import com.logpm.warehouse.entity.WarehouseWayBillDetail; |
||||
import com.logpm.warehouse.entity.WarehouseWaybillEntity; |
||||
import com.logpm.warehouse.feign.IWarehouseWaybillClient; |
||||
import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; |
||||
import com.rabbitmq.client.Channel; |
||||
import jodd.util.ArraysUtil; |
||||
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.ObjectUtil; |
||||
import org.springblade.system.entity.Tenant; |
||||
import org.springblade.system.feign.ISysClient; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
||||
import org.springframework.messaging.Message; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.concurrent.CompletableFuture; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 运单开单数据推送商场 |
||||
* <br> |
||||
* <li>站存单</li> |
||||
* <li>站存单明细</li> |
||||
* <li>运单</li> |
||||
* <li>运单关联信息</li> |
||||
* <li>运单关联暂存单</li> |
||||
* <li>运单关联站存单明细</li> |
||||
*/ |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Component |
||||
@RabbitListener(queues = RabbitConstant.OPEN_WAYBILL_TO_BUSINESS_DATA_QUEUE) |
||||
public class
|
||||
OpenWaybillToBusinessListener { |
||||
|
||||
|
||||
private final IWarehouseWaybillClient warehouseWaybillClient; |
||||
|
||||
private final IWarehouseWaybillDetailClient warehouseWaybillDetailClient; |
||||
|
||||
private final ITrunklineWaybillOrderClient trunklineWaybillOrderClient; |
||||
|
||||
private final ITrunklineWaybillPackageClient trunklineWaybillPackageClient; |
||||
|
||||
private final ITrunklineAdvanceClient trunklineAdvanceClient; |
||||
|
||||
private final ITrunklineAdvanceDetailClient trunklineAdvanceDetailClient; |
||||
private final ISysClient sysClient; |
||||
|
||||
private final IAsyncService asyncService; |
||||
|
||||
private ITrunklineWaybillTrackService trunklineWaybillTrackService; |
||||
|
||||
@RabbitHandler |
||||
public void openWaybillToBusinessDataHandler(Map map, Message message, Channel channel) { |
||||
|
||||
extracted(map); |
||||
|
||||
|
||||
} |
||||
|
||||
private void extracted(Map map) { |
||||
|
||||
|
||||
Long waybillId = (Long) map.get("messageData"); |
||||
if (ObjectUtil.isEmpty(waybillId)) { |
||||
log.warn("运单ID为null"); |
||||
return; |
||||
} |
||||
|
||||
// 获取运单关联的暂存单信息
|
||||
|
||||
WarehouseWaybillEntity byWaybillId = warehouseWaybillClient.findByWaybillId(waybillId); |
||||
|
||||
R<List<Tenant>> tenantList = sysClient.getTenantList(); |
||||
Tenant tenant = null; |
||||
if (tenantList.isSuccess()) { |
||||
List<Tenant> data = tenantList.getData(); |
||||
for (Tenant datum : data) { |
||||
if (datum.getTenantType() == 2 && datum.getTenantName().equals(byWaybillId.getConsignee().trim())) { |
||||
tenant = datum; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (ObjectUtil.isEmpty(tenant)) { |
||||
log.warn(">>>>> 租户不存在"); |
||||
return; |
||||
} |
||||
List<WarehouseWaybillEntity> waybillBilllByWaybillNos = new ArrayList<>(); |
||||
waybillBilllByWaybillNos.add(byWaybillId); |
||||
|
||||
|
||||
|
||||
List<Long> waybillIds = new ArrayList<>(); |
||||
waybillIds.add(waybillId); |
||||
|
||||
List<WarehouseWayBillDetail> warehouseWayBillDetails = warehouseWaybillDetailClient.findByWaybillId(waybillId); |
||||
|
||||
List<TrunklineWaybillOrderEntity> trunklineWaybillOrderEntities = trunklineWaybillOrderClient.findListByWaybillIds(waybillIds); |
||||
|
||||
List<TrunklineWaybillPackageEntity> trunklineWaybillPackageEntities = trunklineWaybillPackageClient.findListByWaybillIds(waybillIds); |
||||
|
||||
// 暂存单ID集合
|
||||
List<Long> collect = trunklineWaybillOrderEntities.stream().map(TrunklineWaybillOrderEntity::getAdvanceId).distinct().collect(Collectors.toList()); |
||||
|
||||
List<TrunklineAdvanceEntity> trunklineAdvanceEntities = trunklineAdvanceClient.findListByIds(collect); |
||||
|
||||
// 获取暂存单明细
|
||||
List<TrunklineAdvanceDetailVO> trunklineAdvanceDetailEntities = trunklineAdvanceDetailClient.findListByAdvanceIds(collect); |
||||
|
||||
|
||||
LambdaQueryWrapper<TrunklineWaybillTrackEntity> queryWrapper = new LambdaQueryWrapper<>(); |
||||
queryWrapper.eq(TrunklineWaybillTrackEntity::getWaybillId, waybillId); |
||||
queryWrapper.eq(TrunklineWaybillTrackEntity::getTrackType, "10"); |
||||
List<TrunklineWaybillTrackEntity> list = trunklineWaybillTrackService.list(queryWrapper); |
||||
TrunklineWaybillTrackEntity trunklineWaybillTrackEntity = list.get(0); |
||||
Tenant finalTenant = tenant; |
||||
CompletableFuture.supplyAsync(() -> { |
||||
asyncService.saveOtherData(finalTenant.getTenantId(), waybillBilllByWaybillNos, trunklineAdvanceDetailEntities, trunklineAdvanceEntities, trunklineWaybillPackageEntities, trunklineWaybillOrderEntities, warehouseWayBillDetails,trunklineWaybillTrackEntity); |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue