diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java index f4c0de04d..d54a35e6d 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/ModuleNameConstant.java @@ -9,7 +9,7 @@ public interface ModuleNameConstant { /** * 如果不需要 "" */ - public static final String DEVAUTH ="-pref"; + public static final String DEVAUTH =""; /** * 工厂对接服务名称 diff --git a/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/dto/BusinessSanDTO.java b/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/dto/BusinessSanDTO.java index 81e7fb05c..5e006a083 100644 --- a/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/dto/BusinessSanDTO.java +++ b/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/dto/BusinessSanDTO.java @@ -15,4 +15,19 @@ public class BusinessSanDTO { @ApiModelProperty(value = "异常入库 0 正常 1 异常") private Integer inWarehouseException; + @ApiModelProperty(value = "仓库id") + private Long warehouseId;//仓库id + + @ApiModelProperty(value = "仓库名称") + private String warehouseName;//仓库 + + @ApiModelProperty(value = "入库类型 1提货扫描入库 2直接入库 3批量入库 4 按车次号入库 5按订单入库") + private Integer incomingType;//入库类型 1提货扫描入库 2直接入库 3批量入库 4 按车次号入库 5按订单入库 + + @ApiModelProperty(value = "托盘码") + private String trayCode;//托盘码 + + @ApiModelProperty(value = "打托方式") + private String trayType;//打托方式 + } diff --git a/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/feign/IBusinessPreOrderClient.java b/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/feign/IBusinessPreOrderClient.java index e06f5d69e..ff0e1c16e 100644 --- a/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/feign/IBusinessPreOrderClient.java +++ b/blade-service-api/logpm-business-api/src/main/java/com/logpm/business/feign/IBusinessPreOrderClient.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @FeignClient( - value = ModuleNameConstant.APPLICATION_DISTRIBUTION_NAME + value = ModuleNameConstant.LOGPM_BUSINESS_NAME ) public interface IBusinessPreOrderClient { String API_PREFIX = "/client"; @@ -23,6 +23,6 @@ public interface IBusinessPreOrderClient { Integer inOrderByOrderPackageCode(@RequestParam("orderPackageCode") String orderPackageCode, @RequestParam("carNum") String carNum); @PostMapping(SAVEOTHERDATABASENEW) - void saveOtherDataBaseNew(@RequestParam("userId") String tenantId, @RequestBody List dataResult, @RequestParam("userId") String mallName); + void saveOtherDataBaseNew(@RequestParam("userId") String tenantId, @RequestBody List dataResult, @RequestParam("mallName") String mallName); } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/IInComingClient.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/IInComingClient.java index bb33a2ad9..318591578 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/IInComingClient.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/IInComingClient.java @@ -16,6 +16,6 @@ public interface IInComingClient { @PostMapping(API_PREFIX+"/incomingPackage") - R incomingPackage(@RequestBody InComingDTO inComingDTO); + R incomingPackageByTaryCode(@RequestBody InComingDTO inComingDTO); } diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/api/BusinessPreOrderApi.java b/blade-service/logpm-business/src/main/java/com/logpm/business/api/BusinessPreOrderApi.java index 1da500608..57439787a 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/api/BusinessPreOrderApi.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/api/BusinessPreOrderApi.java @@ -2,6 +2,7 @@ package com.logpm.business.api; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.business.bean.Resp; import com.logpm.business.dto.BusinessPreListDTO; import com.logpm.business.dto.BusinessSanDTO; @@ -10,16 +11,23 @@ import com.logpm.business.vo.DistributionBusinessPreCarDetalVO; import com.logpm.business.vo.DistributionBusinessPreCarNumerPageQueryVO; import com.logpm.business.vo.DistributionBusinessPreCarNumerPageVO; import com.logpm.business.vo.DistributionBusinessPreOrderListVO; +import com.logpm.trunkline.dto.InComingDTO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.exception.CustomerException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.bind.annotation.*; +import java.util.Objects; + @RestController @AllArgsConstructor +@Slf4j @RequestMapping("/app/businessPreOrder") @Api(value = "配送管理", tags = "预入库管理") public class BusinessPreOrderApi { @@ -73,4 +81,6 @@ public class BusinessPreOrderApi { return R.data(distributionBusinessPreCarDetalVO); } + + } diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/config/CustomMessageConverter.java b/blade-service/logpm-business/src/main/java/com/logpm/business/config/CustomMessageConverter.java new file mode 100644 index 000000000..c8ca3c821 --- /dev/null +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/config/CustomMessageConverter.java @@ -0,0 +1,155 @@ +package com.logpm.business.config; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.AllowedListDeserializingMessageConverter; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.utils.SerializationUtils; +import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream; +import org.springframework.stereotype.Component; +import org.springframework.util.ClassUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.io.*; +import java.util.List; +import java.util.Map; + +/** + * @author zhaoqiaobo + * @create 2024-05-08 + */ +@Component +public class CustomMessageConverter extends AllowedListDeserializingMessageConverter implements BeanClassLoaderAware { + + private final String defaultCharset = "UTF-8"; + private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); + private String codebaseUrl; + + @Deprecated + public void setCodebaseUrl(String codebaseUrl) { + this.codebaseUrl = codebaseUrl; + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + Object content = null; + MessageProperties properties = message.getMessageProperties(); + if (properties != null) { + String contentType = properties.getContentType(); + if (contentType != null && contentType.startsWith("text")) { + String encoding = properties.getContentEncoding(); + if (encoding == null) { + encoding = "UTF-8"; + } + + try { + content = new String(message.getBody(), encoding); + } catch (UnsupportedEncodingException var8) { + throw new MessageConversionException("failed to convert text-based Message content", var8); + } + } else if (contentType != null && contentType.equals("application/x-java-serialized-object")) { + try { + content = SerializationUtils.deserialize(this.createObjectInputStream(new ByteArrayInputStream(message.getBody()), this.codebaseUrl)); + } catch (IllegalArgumentException | IllegalStateException | IOException var7) { + throw new MessageConversionException("failed to convert serialized Message content", var7); + } + } + } + Map headers = properties.getHeaders(); + HttpHeaders httpHeaders = new HttpHeaders(); + for (Map.Entry entry : headers.entrySet()) { + if (StrUtil.equals("Blade-Auth", entry.getKey()) + || StrUtil.equals("Authorization", entry.getKey()) + || StrUtil.equals("blade-auth", entry.getKey()) + || StrUtil.equals("authorization", entry.getKey())) { + List value = (List) entry.getValue(); + for (Object o : value) { + httpHeaders.add(entry.getKey(), String.valueOf(o)); + } + } + } + ThreadLocalUtil.put("bladeContext", httpHeaders); + Object bladeUser = headers.get("bladeUser"); + MockHttpServletRequest request = new MockHttpServletRequest(); + BladeUser bladeUser1 = JSONUtil.toBean(bladeUser.toString(), BladeUser.class); + request.setAttribute("_BLADE_USER_REQUEST_ATTR_", bladeUser1); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + if (content == null) { + content = message.getBody(); + } + return content; + } + + @Override + protected Message createMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { + byte[] bytes = null; + if (object instanceof byte[]) { + bytes = (byte[]) object; + messageProperties.setContentType("application/octet-stream"); + } else if (object instanceof String) { + try { + bytes = ((String) object).getBytes(this.defaultCharset); + } catch (UnsupportedEncodingException var6) { + throw new MessageConversionException("failed to convert to Message content", var6); + } + + messageProperties.setContentType("text/plain"); + messageProperties.setContentEncoding(this.defaultCharset); + } else if (object instanceof Serializable) { + try { + bytes = SerializationUtils.serialize(object); + } catch (IllegalArgumentException var5) { + throw new MessageConversionException("failed to convert to serialized Message content", var5); + } + + messageProperties.setContentType("application/x-java-serialized-object"); + } + HttpHeaders headers = ThreadLocalUtil.get("bladeContext"); + if (headers != null && !headers.isEmpty()) { + headers.forEach((key, values) -> { + values.forEach((value) -> { + messageProperties.setHeader(key, new String[]{value}); + }); + }); + } + BladeUser user = AuthUtil.getUser(); + BladeUser bladeUser = new BladeUser(); + bladeUser.setTenantId(user.getTenantId()); + bladeUser.setUserId(user.getUserId()); + bladeUser.setAccount(user.getAccount()); + bladeUser.setRoleId(user.getRoleId()); + messageProperties.setHeader("bladeUser", JSONUtil.toJsonStr(bladeUser)); + + if (bytes != null) { + messageProperties.setContentLength(bytes.length); + return new Message(bytes, messageProperties); + } else { + throw new IllegalArgumentException(this.getClass().getSimpleName() + " only supports String, byte[] and Serializable payloads, received: " + object.getClass().getName()); + } + } + + @Override + public void setBeanClassLoader(ClassLoader classLoader) { + this.beanClassLoader = beanClassLoader; + } + + protected ObjectInputStream createObjectInputStream(InputStream is, String codebaseUrl) throws IOException { + return new CodebaseAwareObjectInputStream(is, this.beanClassLoader, codebaseUrl) { + @Override + protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { + Class clazz = super.resolveClass(classDesc); + CustomMessageConverter.this.checkAllowedList(clazz); + return clazz; + } + }; + } +} diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/config/RabbitMqConfiguration.java b/blade-service/logpm-business/src/main/java/com/logpm/business/config/RabbitMqConfiguration.java new file mode 100644 index 000000000..3150f558e --- /dev/null +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/config/RabbitMqConfiguration.java @@ -0,0 +1,208 @@ +package com.logpm.business.config; + +import com.alibaba.nacos.shaded.com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.RabbitConstant; +import org.springframework.amqp.core.*; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.rabbit.retry.MessageRecoverer; +import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * RabbitMQ配置,主要是配置队列,如果提前存在该队列,可以省略本配置类 + * + * @author yangkai.shen + */ +@Slf4j +@Configuration +public class RabbitMqConfiguration { + + @Bean + public RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory){ + RabbitTemplate template = new RabbitTemplate(); + template.setConnectionFactory(connectionFactory); + template.setMandatory(true); + template.setMessageConverter(new CustomMessageConverter()); + template.setConfirmCallback(new RabbitTemplate.ConfirmCallback() { + @Override + public void confirm(CorrelationData correlationData, boolean b, String s) { + System.out.println("确认回调-相关数据:"+correlationData); + System.out.println("确认回调-确认情况:"+b); + System.out.println("确认回调-原因:"+s); + } + }); + + template.setReturnsCallback(new RabbitTemplate.ReturnsCallback() { + @Override + public void returnedMessage(ReturnedMessage returnedMessage) { + System.out.println("返回回调-消息:"+returnedMessage.getMessage()); + System.out.println("返回回调-回应码:"+returnedMessage.getReplyCode()); + System.out.println("返回回调-回应信息:"+returnedMessage.getReplyText()); + System.out.println("返回回调-交换机:"+returnedMessage.getExchange()); + System.out.println("返回回调-路由键:"+returnedMessage.getRoutingKey()); + } + }); + return template; + } + + @Bean + public DirectExchange distributionErrorMessageExchange(){ + return new DirectExchange(RabbitConstant.DISTRIBUTION_ERROR_EXCHANGE); + } + @Bean + public Queue distributionErrorQueue(){ + return new Queue(RabbitConstant.DISTRIBUTION_ERROR_QUEUE, true); + } + @Bean + public Binding distributionErrorBinding(Queue distributionErrorQueue, DirectExchange distributionErrorMessageExchange){ + return BindingBuilder.bind(distributionErrorQueue).to(distributionErrorMessageExchange).with(RabbitConstant.DISTRIBUTION_ERROR_ROUTING); + } + + /** + * 消费失败队列 + * @param rabbitTemplate + * @return + */ + @Bean + public MessageRecoverer republishMessageRecoverer(RabbitTemplate rabbitTemplate){ + return new RepublishMessageRecoverer(rabbitTemplate, RabbitConstant.DISTRIBUTION_ERROR_EXCHANGE, RabbitConstant.DISTRIBUTION_ERROR_ROUTING); + } + + + /** + * 备货扫码任务队列 + */ + @Bean + public Queue stockupScanQueue() { + return new Queue(RabbitConstant.STOCKUP_SCAN_QUEUE, true); + } + @Bean + public CustomExchange stockupScanExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.STOCKUP_SCAN_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding stockupScanBinding(Queue stockupScanQueue, CustomExchange stockupScanExchange) { + return BindingBuilder.bind(stockupScanQueue).to(stockupScanExchange).with(RabbitConstant.STOCKUP_SCAN_ROUTING).noargs(); + } + + /** + * 备货判断是否下架任务队列 + */ + @Bean + public Queue stockupStateUpdateQueue() { + return new Queue(RabbitConstant.STOCKUP_STATE_UPDATE_QUEUE, true); + } + @Bean + public CustomExchange stockupStateUpdateExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.STOCKUP_STATE_UPDATE_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding stockupStateUpdateBinding(Queue stockupStateUpdateQueue, CustomExchange stockupStateUpdateExchange) { + return BindingBuilder.bind(stockupStateUpdateQueue).to(stockupStateUpdateExchange).with(RabbitConstant.STOCKUP_STATE_UPDATE_ROUTING).noargs(); + } + + + /** + * 文员签收复合推送老系统队列 + * @return + */ + @Bean + public Queue clerkCheckPushDataQueue() { + return new Queue(RabbitConstant.CLERK_CHECK_PUSH_DATA_QUEUE, true); + } + @Bean + public CustomExchange clerkCheckPushDataExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.CLERK_CHECK_PUSH_DATA_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding clerkCheckPushDataBinding(Queue clerkCheckPushDataQueue, CustomExchange clerkCheckPushDataExchange) { + return BindingBuilder.bind(clerkCheckPushDataQueue).to(clerkCheckPushDataExchange).with(RabbitConstant.CLERK_CHECK_PUSH_DATA_ROUTING).noargs(); + } + + + + @Bean + public Queue orderPackageStatusInfoQueue() { + return new Queue(RabbitConstant.ORDER_PACKAGE_STATUS_INFO_QUEUE, true); + } + @Bean + public CustomExchange orderPackageStatusInfoExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.ORDER_PACKAGE_STATUS_INFO_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding orderPackageStatusInfoBinding(Queue orderPackageStatusInfoQueue, CustomExchange orderPackageStatusInfoExchange) { + return BindingBuilder.bind(orderPackageStatusInfoQueue).to(orderPackageStatusInfoExchange).with(RabbitConstant.ORDER_PACKAGE_STATUS_INFO_ROUTING).noargs(); + } + + + + + /** + * 文员签收复合推送老系统队列 + * @return + */ + @Bean + public Queue billClerkCheckPushDataQueue() { + return new Queue(RabbitConstant.BILL_CLERK_CHECK_PUSH_DATA_QUEUE, true); + } + @Bean + public CustomExchange billClerkCheckPushDataExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.BILL_CLERK_CHECK_PUSH_DATA_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding billCclerkCheckPushDataBinding(Queue billClerkCheckPushDataQueue, CustomExchange billClerkCheckPushDataExchange) { + return BindingBuilder.bind(billClerkCheckPushDataQueue).to(billClerkCheckPushDataExchange).with(RabbitConstant.BILL_CLERK_CHECK_PUSH_DATA_ROUTING).noargs(); + } + + + + + + + @Bean + public Queue businessInConversionQueue() { + return new Queue(RabbitConstant.BUSINESS_IN_CONVERSION_DATA_QUEUE, true); + } + @Bean + public CustomExchange businessInConversionExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.BUSINESS_IN_CONVERSION_DATA_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding businessInConversionBinding(Queue businessInConversionQueue, CustomExchange businessInConversionExchange) { + return BindingBuilder.bind(businessInConversionQueue).to(businessInConversionExchange).with(RabbitConstant.BUSINESS_IN_CONVERSION_DATA_ROUTING).noargs(); + } + + @Bean + public Queue selfPickupScanQueue() { + return new Queue(RabbitConstant.SELF_PICKUP_SCAN_QUEUE, true); + } + @Bean + public CustomExchange selfPickupScanExchange() { + Map args = Maps.newHashMap(); + args.put("x-delayed-type", "direct"); + return new CustomExchange(RabbitConstant.SELF_PICKUP_SCAN_EXCHANGE, "x-delayed-message", true, false, args); + } + @Bean + public Binding selfPickupScanBinding(Queue selfPickupScanQueue, CustomExchange selfPickupScanExchange) { + return BindingBuilder.bind(selfPickupScanQueue).to(selfPickupScanExchange).with(RabbitConstant.SELF_PICKUP_SCAN_ROUTING).noargs(); + } + +} diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/service/IBusinessPreOrderService.java b/blade-service/logpm-business/src/main/java/com/logpm/business/service/IBusinessPreOrderService.java index f1bf794f5..ccc14e05c 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/service/IBusinessPreOrderService.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/service/IBusinessPreOrderService.java @@ -6,8 +6,10 @@ import com.logpm.business.dto.BusinessPreListDTO; import com.logpm.business.dto.BusinessSanDTO; import com.logpm.business.entity.BusinessPreOrderEntity; import com.logpm.business.vo.*; +import com.logpm.trunkline.dto.InComingDTO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.tool.api.R; import java.util.List; import java.util.Map; @@ -69,4 +71,10 @@ public interface IBusinessPreOrderService extends BaseService listCarNum(IPage page, DistributionBusinessPreCarNumerPageQueryVO distributionBusinessPreCarNumerPageQueryVO); + /** + * 商家端托盘扫码入库 + * @param inComingDTO + * @return + */ + R incomingPackage(InComingDTO inComingDTO); } diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java index dad81100e..b95378ab7 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java @@ -30,6 +30,7 @@ import org.springblade.core.redis.cache.BladeRedis; 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.StringUtil; import org.springframework.stereotype.Service; import java.util.*; @@ -41,12 +42,13 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl - lds.delivery_id = #{param.deliveryId} and ldrp.packet_bar_status in ('1','3') and ldpl.id is not null + lds.delivery_id = #{param.deliveryId} and ldrp.packet_bar_status in (1,3) and ldpl.id is not null and ldpl.waybill_number like concat('%',#{param.waybillNumber},'%') diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java index 84d742f4e..4c3b791e4 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java @@ -85,7 +85,7 @@ public interface DistributionStockArticleMapper extends BaseMapper fingListByServiceNumber(@Param("serviceNumber") String serviceNumber,@Param("warehouseId") Long warehouseId); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml index 85779b244..8d0044eae 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml @@ -354,7 +354,14 @@ LEFT JOIN logpm_distribution_stock_article ldsa on ldpl.stock_article_id = ldsa.id LEFT JOIN logpm_warehouse_waybill lww on lww.waybill_no= ldsa.waybill_number - ldpl.id = #{o} + + + and ldpl.order_package_code = #{qrCode} + + + and ldpl.id = #{o} + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java index 6d5f7131d..f54f83f2f 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java @@ -298,4 +298,5 @@ public interface IDistributionStockArticleService extends BaseService signforListDetail(Long id); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java index 836956fff..af92914c2 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java @@ -692,7 +692,7 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl map = orderNoList.toMap(); // 创建一个新的Map,并将map1和map2合并到其中 Map mergedMap = new HashMap<>(); @@ -795,6 +795,8 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl handlePackage(IPage pageVO) { diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/InComingClient.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/InComingClient.java index 901f1822a..fdbff1cae 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/InComingClient.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/InComingClient.java @@ -15,8 +15,8 @@ import springfox.documentation.annotations.ApiIgnore; public class InComingClient implements IInComingClient{ private final IInComingService inComingService; @Override - public R incomingPackage(InComingDTO inComingDTO) { + public R incomingPackageByTaryCode(InComingDTO inComingDTO) { - return inComingService.incomingPackage(inComingDTO); + return inComingService.incomingPackageByTaryCode(inComingDTO); } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java index cadfb11c6..1af3368d7 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IInComingService.java @@ -3,6 +3,7 @@ package com.logpm.trunkline.service; import com.logpm.trunkline.dto.InComingDTO; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.springblade.core.tool.api.R; +import org.springframework.transaction.annotation.Transactional; public interface IInComingService { @@ -10,7 +11,10 @@ public interface IInComingService { R incomingPackages(InComingDTO inComingDTO); - R findIncomingOrderList(InComingDTO inComingDTO); + @Transactional(rollbackFor = Exception.class) + R incomingPackageByTaryCode(InComingDTO inComingDTO); + + R findIncomingOrderList(InComingDTO inComingDTO); R incomingBatchOrder(InComingDTO inComingDTO, WarehouseWaybillEntity waybillEntity); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java index c8d92067b..0df5024c7 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/AsyncServiceImpl.java @@ -274,7 +274,6 @@ public class AsyncServiceImpl implements IAsyncService { private void saveTrunklineAdvanceDetailEntity(List t, TrunklineAdvanceEntity trunklineAdvanceEntity, String mallName) { Tenant tenant = changeDataBase(mallName); - List ids = Collections.singletonList(trunklineAdvanceEntity.getId()); List listByAdvanceIds = advanceDetailService.findAdvanceDetailVoByAdvanceIds(ids); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java index 7f5eb0c13..c198facc3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java @@ -3,7 +3,6 @@ package com.logpm.trunkline.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; @@ -186,6 +185,10 @@ public class InComingServiceImpl implements IInComingService { } + + + + @Transactional(rollbackFor = Exception.class) public R incomingPackage(InComingDTO inComingDTO) { try{ @@ -430,6 +433,170 @@ public class InComingServiceImpl implements IInComingService { } + + @Override + @Transactional(rollbackFor = Exception.class) + public R incomingPackageByTaryCode(InComingDTO inComingDTO) { + try{ + String orderPackageCode = inComingDTO.getOrderPackageCode();//包件码 + Long warehouseId = inComingDTO.getWarehouseId();//仓库id + String warehouseName = inComingDTO.getWarehouseName(); + if (StringUtil.isBlank(warehouseName)) { + BasicdataWarehouseEntity warehouseEntity = warehouseClient.getEntityWarehouseId(warehouseId); + if (!Objects.isNull(warehouseEntity)) { + warehouseName = warehouseEntity.getName(); + } + } + Long billladingId = inComingDTO.getBillladingId();//提货单id + Integer incomingType = inComingDTO.getIncomingType();//入库类型 1码板打托 2扫码入库 3直接入库 4 按车次号入库 5按订单入库 6扫描入库 7 批量卸车入库 8卸车托盘 9卸分一体 10补录数据入库 + String trayCode = inComingDTO.getTrayCode();//托盘码 + String trayType = inComingDTO.getTrayType();//打托方式 + String customerTrain = inComingDTO.getCustomerTrain();//车次号 + + List packageCodes = Arrays.asList(orderPackageCode.split(",")); + log.info("############incomingPackage: 包件入库开始 packageCodes={} billladingId={} warehouseId={}", packageCodes, billladingId, warehouseId); + //包件入库开始 + //查询包件是否有数据 + QueryWrapper advanceDetailQueryWrapper = new QueryWrapper<>(); + advanceDetailQueryWrapper.in("order_package_code", packageCodes); + List advanceDetailEntityList = advanceDetailService.list(advanceDetailQueryWrapper); + if (advanceDetailEntityList.isEmpty()) { + log.warn("############incomingPackage: 包件不存在 packageCodes={} warehouseId={}", packageCodes, warehouseId); + return Resp.scanFail(405, "包件无数据", "包件无数据"); + } + if(StringUtil.isNotBlank(customerTrain)){ + for (TrunklineAdvanceDetailEntity advanceDetailEntity : advanceDetailEntityList) { + String trainNumber = advanceDetailEntity.getTrainNumber(); + if(!trainNumber.equals(customerTrain)){ + log.warn("############incomingPackage: 包件车次号不一致 packageCodes={} trainNumber={} trainNumber={}", packageCodes, trainNumber, customerTrain); + return Resp.scanFail(405, "包件车次号不一致", "包件车次号不一致"); + } + } + } + + //把advanceDetailEntityList通过packageStatus分组 + Map> advanceDetailEntityMap = advanceDetailEntityList.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getPackageStatus)); + + //把advanceDetailEntityList的orderCode提取成一个Set +// Set orderCodes = advanceDetailEntityList.stream().map(TrunklineAdvanceDetailEntity::getOrderCode).collect(Collectors.toSet()); + + String finalWarehouseName = warehouseName; + advanceDetailEntityMap.keySet().forEach(packageStatus -> { + List advanceDetailEntities = advanceDetailEntityMap.get(packageStatus); + if (!advanceDetailEntities.isEmpty()) { + //提取advanceDetailEntities中所有元素的orderPackageCode组成一个List + List orderPackageCodes = advanceDetailEntities.stream() + .map(TrunklineAdvanceDetailEntity::getOrderPackageCode) + .collect(Collectors.toList()); + + if ("0".equals(packageStatus)) { + //未入库包件 + + Set advanceIds = new HashSet<>(); + //1.修改暂存单包件入库状态 + advanceDetailEntities.forEach(advanceDetailEntity -> { + advanceIds.add(advanceDetailEntity.getId()); + advanceDetailEntity.setPackageStatus("1"); + advanceDetailEntity.setIncomingTime(new Date()); + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(finalWarehouseName); + }); + + advanceDetailService.updateBatchById(advanceDetailEntities); + + advanceIds.forEach(advanceId -> { + List incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId); + advanceService.updateIncomingWarehouseName(String.join(",", incomingWarehouseNames), advanceId); + }); + +// advanceDetailService.updatePackageStatusById("1", advanceDetailId, warehouseId, warehouseName,new Date()); +// List incomingWarehouseNames = advanceDetailService.findIncomingWarehouseName(advanceId); +// advanceService.updateIncomingWarehouseName(String.join(",", incomingWarehouseNames), advanceId); +// +// List orderPackageCodes = new ArrayList<>(); +// orderPackageCodes.add(orderPackageCode); + //存入日志 + packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, finalWarehouseName, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode(), "包件" + IncomingTypeEnum.getValue(incomingType)); + + + //2.判断包件和订单是否已经存入在库订单 + boolean b = advanceService.saveOrderAndPackages(advanceDetailEntities, warehouseId); + if (b) { + + //把advanceDetailEntities通过waybillNo进行分组 + Map> advanceDetailEntityWaybillNoMap = advanceDetailEntities.stream().filter(entity -> StringUtil.isNotBlank(entity.getWaybillNo())).collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getWaybillNo)); + + Set waybillNoSet = advanceDetailEntityWaybillNoMap.keySet(); + if(!waybillNoSet.isEmpty()){ + + List waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet)); + //把waybillEntityList转化成waybillNo为key的map + Map waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity())); + + advanceDetailEntityWaybillNoMap.keySet().forEach(waybillNo -> { + List waybillNoAdvanceDetailEntities = advanceDetailEntityWaybillNoMap.get(waybillNo); + if(!waybillNoAdvanceDetailEntities.isEmpty()){ + WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo); + if(!Objects.isNull(waybillEntity)){ + Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); + if(departureWarehouseId!=null&&departureWarehouseId.equals(warehouseId)){ + Integer totalCount = waybillEntity.getTotalCount(); + Integer stockCount = waybillEntity.getStockCount(); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "20", "已入库", "运单入库:"+stockCount+"/"+totalCount+",入库类型:【"+IncomingTypeEnum.getValue(incomingType)+"】,入库时间:"+ CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, finalWarehouseName); + } + } + } + }); + } + + + //4.如果有托盘码 + orderPackageCodes.forEach(packageCode -> { + if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) { + Map map = new HashMap<>(); + map.put("trayType", trayType); + map.put("trayCode", trayCode); + map.put("warehouseId", warehouseId); + map.put("orderPackageCode", packageCode); + warehouseTrayTypeClient.orderScanOrderPackageCode(map); + } + }); + } + + + + } else if ("1".equals(packageStatus)) { + //已入库包件 + if (incomingType != 1) { + log.warn("############incomingPackage: 包件已入库 orderPackageCodes={} warehouseId={}", orderPackageCodes, warehouseId); + throw new CustomerException(405, "包件" + orderPackageCodes + "已入库"); + } else { + + //4.如果有托盘码 + orderPackageCodes.forEach(packageCode -> { + if (StringUtil.isNotBlank(trayCode) && StringUtil.isNotBlank(trayType)) { + Map map = new HashMap<>(); + map.put("trayType", trayType); + map.put("trayCode", trayCode); + map.put("warehouseId", warehouseId); + map.put("orderPackageCode", packageCode); + warehouseTrayTypeClient.orderScanOrderPackageCode(map); + } + }); + } + } + } + }); + }catch (Exception e){ + e.printStackTrace(); + log.error("入库异常",e); + throw new CustomerException("系统异常,请联系管理员"); + } + + return R.success("入库成功"); + } + + @Override public R findIncomingOrderList(InComingDTO inComingDTO) { Integer incomingType = inComingDTO.getIncomingType();