From 090e7d7cab5993d06fc422b6cb5230f4a469e4b9 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 17 Dec 2024 13:37:50 +0800 Subject: [PATCH] =?UTF-8?q?2.=E5=A2=9E=E5=8A=A0=E8=BF=90=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BD=9C=E4=B8=9A=E5=AF=B9=E5=A4=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=201.=E4=BF=AE=E6=94=B9=E6=89=93=E6=89=98=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logpm-data-sharing-api/pom.xml | 18 ++ .../datasharing/dto/MerchantOrderDTO.java | 0 .../vo/MerchantOrderPackageVO.java | 0 .../logpm/datasharing/vo/MerchantOrderVO.java | 0 .../datasharing/vo/MerchantOrderZeroVO.java | 0 .../datasharing/vo/MerchantPackageVO.java | 0 .../vo/MerchantZeroDispatchVO.java | 0 .../datasharing/vo/WarehouseNumberVO.java | 26 +++ .../logpm/datasharing/vo/WaybillInfoVO.java | 137 ++++++++++++++ blade-service-api/pom.xml | 5 +- .../controller/BasicdataTrayController.java | 9 +- .../basicdata/mapper/BasicdataTrayMapper.java | 1 + .../basicdata/mapper/BasicdataTrayMapper.xml | 15 ++ .../impl/BasicdataTrayServiceImpl.java | 8 +- blade-service/logpm-data-sharing/pom.xml | 11 ++ .../config/InterceptorAdapterConfig.java | 33 ++++ .../controller/LogpmDataSearchController.java | 13 +- .../controller/MerchantController.java | 3 +- .../LocalServerLoginAccountsInterceptor.java | 100 +++++++++++ .../impl/LogpmDataSearchServiceImpl.java | 167 +++++++++++++++++- .../mapper/DistributionParcelListMapper.xml | 2 +- .../feign/WarehouseWaybillClient.java | 1 - .../mapper/WarehouseWaybillMapper.xml | 1 + 23 files changed, 531 insertions(+), 19 deletions(-) create mode 100644 blade-service-api/logpm-data-sharing-api/pom.xml rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/dto/MerchantOrderDTO.java (100%) rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/vo/MerchantOrderPackageVO.java (100%) rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/vo/MerchantOrderVO.java (100%) rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/vo/MerchantOrderZeroVO.java (100%) rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/vo/MerchantPackageVO.java (100%) rename {blade-service/logpm-data-sharing => blade-service-api/logpm-data-sharing-api}/src/main/java/com/logpm/datasharing/vo/MerchantZeroDispatchVO.java (100%) create mode 100644 blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WarehouseNumberVO.java create mode 100644 blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WaybillInfoVO.java create mode 100644 blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/config/InterceptorAdapterConfig.java create mode 100644 blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/interceptor/LocalServerLoginAccountsInterceptor.java diff --git a/blade-service-api/logpm-data-sharing-api/pom.xml b/blade-service-api/logpm-data-sharing-api/pom.xml new file mode 100644 index 000000000..943b859db --- /dev/null +++ b/blade-service-api/logpm-data-sharing-api/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + + org.springblade + blade-service-api + 3.2.0.RELEASE + + + org.springblade + logpm-data-sharing-api + 3.2.0.RELEASE + + + diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/dto/MerchantOrderDTO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/dto/MerchantOrderDTO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/dto/MerchantOrderDTO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/dto/MerchantOrderDTO.java diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderPackageVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderPackageVO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderPackageVO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderPackageVO.java diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderVO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderVO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderVO.java diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderZeroVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderZeroVO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantOrderZeroVO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantOrderZeroVO.java diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantPackageVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantPackageVO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantPackageVO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantPackageVO.java diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantZeroDispatchVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantZeroDispatchVO.java similarity index 100% rename from blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/vo/MerchantZeroDispatchVO.java rename to blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/MerchantZeroDispatchVO.java diff --git a/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WarehouseNumberVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WarehouseNumberVO.java new file mode 100644 index 000000000..cb41f3b9b --- /dev/null +++ b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WarehouseNumberVO.java @@ -0,0 +1,26 @@ +package com.logpm.datasharing.vo; + +import lombok.Data; + +/** + * @see com.logpm.datasharing.vo.WarehouseNumberVO + * 仓库数据 + *
  • 始发仓
  • + *
  • 中转仓
  • + *
  • 目的仓
  • + */ +@Data +public class WarehouseNumberVO { + + /** + * 仓库名称 + */ + private String warehouseName; + + /** + * 数量 + */ + private Integer number; + + +} diff --git a/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WaybillInfoVO.java b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WaybillInfoVO.java new file mode 100644 index 000000000..fe661bb55 --- /dev/null +++ b/blade-service-api/logpm-data-sharing-api/src/main/java/com/logpm/datasharing/vo/WaybillInfoVO.java @@ -0,0 +1,137 @@ +package com.logpm.datasharing.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 开放模块 + * 运单返回诗句 + */ +@Data +public class WaybillInfoVO implements Serializable { + private static final long serialVersionUID = 1L; + + + /** + * 运单状态 10部分入库 + * + * 20入库 + * + * 30部分中转 + * + * 40 中转 + * + * 50 目的仓部分到达 + * + * 60 目的仓到达 + * + * 70 配送部分装车 + * + * 80 配送装车 + * + * 90 部分签收 + * + * 100 已签收 + */ + @ApiModelProperty(value = "运单状态") + private String statusName; + + + /** + * 运单号 + */ + @ApiModelProperty(value = "运单号") + private String waybillNo; + + /** + * 目的仓 + */ + @ApiModelProperty(value = "目的仓") + private String destinationWarehouseName; + + + + /** + * 发站仓 + */ + @ApiModelProperty(value = "发站仓") + private String departureWarehouseName; + + + /** + * 发货单位 + */ + @ApiModelProperty(value = "发货单位") + private String shipper; + + /** + * 发货人 + */ + @ApiModelProperty(value = "发货人") + private String shipperName; + + /** + * 总数 + */ + @ApiModelProperty(value = "总数") + private Integer totalCount; + + + /** + * 在途数量 + */ + @ApiModelProperty(value = "总数") + private Integer onWayCount; + + + /** + * 收货单位 + */ + @ApiModelProperty(value = "收货单位") + private String consignee; + + /** + * 收货人 + */ + @ApiModelProperty(value = "收货人") + private String consigneeName; + + + /** + * 始发仓数量信息 + */ + @ApiModelProperty(value = "始发仓数量信息") + private WarehouseNumberVO startWarehouseNumber; + + + /** + * 中转仓数量信息 + */ + @ApiModelProperty(value = "中转仓数量信息") + private List middleWarehouseNumber; + + /** + * 目的仓数量信息 + */ + @ApiModelProperty(value = "目的仓数量信息") + private WarehouseNumberVO endWarehouseNumber; + + /** + * 配送数量 + */ + @ApiModelProperty(value = "配送数量") + private Integer deliveryNum ; + + /** + * 签收数量 + */ + @ApiModelProperty(value = "签收数量") + private Integer signNum; + + + + +} diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index 6ff42ac06..7d3b3201e 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -45,8 +45,11 @@ logpm-factory-data-zbom-api - + logpm-business-api + + + logpm-data-sharing-api diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTrayController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTrayController.java index 181cc29e4..f84410ba4 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTrayController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTrayController.java @@ -260,10 +260,15 @@ public class BasicdataTrayController extends BladeController { return R.data(trayService.printCode(Func.toLongList(ids))); } - @GetMapping("/getPDF") - public void getPDF(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, + @PostMapping("/downPdf") + public void downPdf(@RequestBody Map map, HttpServletResponse response) throws Exception { + + + String ids = (String) map.get("ids"); +// System.out.println(ids); trayService.downloadCodePDF(Func.toLongList(ids), response); + return ; } /** diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.java index 9574f1586..012de62b6 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.java @@ -87,4 +87,5 @@ public interface BasicdataTrayMapper extends BaseMapper { * 托盘 零担历史记录 */ WarehouseTrayQRCode getTray(@Param("id") Long id); + List getTrayByIds(@Param("ids") List ids); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.xml index ab5139983..ebb6bd105 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.xml +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataTrayMapper.xml @@ -421,6 +421,21 @@ + diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java index 727cebbb9..f23b33356 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTrayServiceImpl.java @@ -280,8 +280,12 @@ public class BasicdataTrayServiceImpl extends BaseServiceImpl trayQRCodes = baseMapper.getTrayByIds(ids); + + for (WarehouseTrayQRCode trayQRCode : trayQRCodes) { +// WarehouseTrayQRCode trayQRCode = baseMapper.getTray(id); String filename = QRCodeUtil.createCodeToFile(trayQRCode.getTrayCode()); String fileTypeName = QRCodeUtil.createCodeToFileType(trayQRCode.getTrayCode()); diff --git a/blade-service/logpm-data-sharing/pom.xml b/blade-service/logpm-data-sharing/pom.xml index 1baf0111b..893a94e33 100644 --- a/blade-service/logpm-data-sharing/pom.xml +++ b/blade-service/logpm-data-sharing/pom.xml @@ -35,6 +35,17 @@ logpm-basicdata-api 3.2.0.RELEASE + + org.springblade + logpm-warehouse-api + 3.2.0.RELEASE + + + org.springblade + logpm-data-sharing-api + 3.2.0.RELEASE + + diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/config/InterceptorAdapterConfig.java b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/config/InterceptorAdapterConfig.java new file mode 100644 index 000000000..1364d45a4 --- /dev/null +++ b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/config/InterceptorAdapterConfig.java @@ -0,0 +1,33 @@ +package com.logpm.datasharing.config; + + +import com.logpm.datasharing.interceptor.LocalServerLoginAccountsInterceptor; +import lombok.AllArgsConstructor; +import org.springblade.common.component.MockLoginService; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.redis.lock.RedisLockClient; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 为所有的的 + */ +@Configuration +@AllArgsConstructor +public class InterceptorAdapterConfig implements WebMvcConfigurer { + + + private final BladeRedis redis; + + private final RedisLockClient redisLockClient; + private final MockLoginService mockLoginService; + + + @Override + public void addInterceptors(InterceptorRegistry interceptorRegistry) { + + interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis,redisLockClient,mockLoginService)).addPathPatterns("/search/**").order(1); + + } +} diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/LogpmDataSearchController.java b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/LogpmDataSearchController.java index ff0598cb8..b501bbb73 100644 --- a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/LogpmDataSearchController.java +++ b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/LogpmDataSearchController.java @@ -1,5 +1,6 @@ package com.logpm.datasharing.controller; +import com.logpm.datasharing.service.ILogpmDataSearchService; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; @@ -24,22 +25,18 @@ import org.springframework.web.bind.annotation.RestController; @Api(value = "运单/订单查询", tags = "运单/订单查询") public class LogpmDataSearchController extends BladeController { + private final ILogpmDataSearchService logpmDataSearchService; /** * 订单/运单搜索 * @return */ - @GetMapping("/data/${type}/${order}") - public R data(@PathVariable("order") String order){ + @GetMapping("/data/{type}/{order}") + public R data(@PathVariable("type") String type,@PathVariable("order") String order){ - - - - - - return null; + return logpmDataSearchService.data(type, order); } diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/MerchantController.java b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/MerchantController.java index 5b978ea11..86637b35c 100644 --- a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/MerchantController.java +++ b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/controller/MerchantController.java @@ -41,10 +41,11 @@ public class MerchantController extends BladeController { private final MerchantService merchantService; - @GetMapping("goods") + @GetMapping("/goods") public R goods(@RequestParam("contract_number") String contract_number, @RequestParam("auth_key") String auth_key) { return R.data(merchantService.goods(contract_number, auth_key)); } + } diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/interceptor/LocalServerLoginAccountsInterceptor.java b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/interceptor/LocalServerLoginAccountsInterceptor.java new file mode 100644 index 000000000..2fc1a3960 --- /dev/null +++ b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/interceptor/LocalServerLoginAccountsInterceptor.java @@ -0,0 +1,100 @@ +package com.logpm.datasharing.interceptor; + +import com.alibaba.fastjson.JSONObject; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.common.cache.CacheNames; +import org.springblade.common.component.MockLoginService; +import org.springblade.common.exception.CustomerException; +import org.springblade.common.wrapper.CustomHttpServletRequestWrapper; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.redis.lock.LockType; +import org.springblade.core.redis.lock.RedisLockClient; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.http.HttpHeaders; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +@Log4j2 +@AllArgsConstructor +public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter { + + private final BladeRedis bladeRedis; + private final RedisLockClient redisLockClient; + private final MockLoginService mockLoginService; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { + + + try { + CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); + String account ="shujutongbu"; + String tenantId = request.getHeader("tenantId"); + tenantId = StringUtil.isBlank(tenantId)?"627683":tenantId; + String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account; + String lockKey =key+":lock"; + JSONObject data =bladeRedis.get(key); + if(Objects.isNull(data)){ + boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); + if(flag){ + data =bladeRedis.get(key); + if(Objects.isNull(data)){ + data = mockLoginService.mockToken(tenantId,account); + bladeRedis.setEx(key,data,2591990L); + redisLockClient.unLock(lockKey, LockType.FAIR); + } + } + } + + // 修改或添加header + + // 发送登录请求 + log.info("##########preHandle: request={}", request); + + wrappedRequest.addHeader("Blade-Auth", "bearer "+data.getString("access_token")); + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); + httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0"); + ThreadLocalUtil.put("bladeContext", httpHeaders); + + + // 用包装后的request替换原始request + request = wrappedRequest; + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return true; + } catch (Exception e) { + returnJson(response, JSONObject.toJSONString(R.fail(500, "服务异常,请联系管理员"))); + return false; + } + } + + private void returnJson(HttpServletResponse response, String json) { + PrintWriter writer = null; + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json"); + try { + writer = response.getWriter(); + writer.print(json); + + } catch (IOException e) { + System.out.println(e.getMessage()); + } finally { + if (writer != null) { + writer.close(); + } + } + } + + +} diff --git a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/service/impl/LogpmDataSearchServiceImpl.java b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/service/impl/LogpmDataSearchServiceImpl.java index b1094c908..53decf3c1 100644 --- a/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/service/impl/LogpmDataSearchServiceImpl.java +++ b/blade-service/logpm-data-sharing/src/main/java/com/logpm/datasharing/service/impl/LogpmDataSearchServiceImpl.java @@ -1,11 +1,28 @@ package com.logpm.datasharing.service.impl; import com.logpm.datasharing.service.ILogpmDataSearchService; +import com.logpm.datasharing.vo.WarehouseNumberVO; +import com.logpm.datasharing.vo.WaybillInfoVO; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.feign.IDistributionParcelListClient; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; +import com.logpm.warehouse.feign.IWarehouseWaybillClient; +import lombok.AllArgsConstructor; +import org.springblade.common.exception.CustomerException; import org.springblade.core.tool.api.R; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.stream.Collectors; + @Service +@AllArgsConstructor public class LogpmDataSearchServiceImpl implements ILogpmDataSearchService { + + + private final IWarehouseWaybillClient warehouseWaybillClient; + private final IDistributionParcelListClient distributionParcelListClient; + @Override public R data(String type, String order) { @@ -18,23 +35,167 @@ public class LogpmDataSearchServiceImpl implements ILogpmDataSearchService { case "waybill": // 运单查询 - break; + return R.data(dataWEaybill(order)) ; default: // 需要没有参数的查询全部的情况 return R.fail("参数错误"); } + } + + + /** + * 运单查询 + * @param waybillNo + * @return + */ + private WaybillInfoVO dataWEaybill(String waybillNo) { + + WaybillInfoVO result = new WaybillInfoVO(); + int temp =0; + // todo 查询运单 + WarehouseWaybillEntity byWaybillNo = warehouseWaybillClient.findByWaybillNo(waybillNo); + if(Objects.isNull(byWaybillNo)){ + throw new CustomerException("运单信息不存在~"); + } + result.setWaybillNo(byWaybillNo.getWaybillNo()); + result.setDestinationWarehouseName(byWaybillNo.getDestinationWarehouseName()); + result.setDepartureWarehouseName(byWaybillNo.getDepartureWarehouseName()); + result.setShipper(byWaybillNo.getShipper()); + result.setShipperName(byWaybillNo.getShipperName()); + result.setConsignee(byWaybillNo.getConsignee()); + result.setConsigneeName(byWaybillNo.getConsigneeName()); + result.setTotalCount(byWaybillNo.getTotalCount()); + + List distributionParcelListEntities = distributionParcelListClient.findByWaybillNumber(waybillNo); + // 按照仓库ID进行分组 + Map> groupedByWarehouse= distributionParcelListEntities.stream() + .collect(Collectors.groupingBy(DistributionParcelListEntity::getWarehouse)); + + // 获取始发仓的入库数据 + WarehouseNumberVO startWarehouseNumber =buildWarehouse(groupedByWarehouse,result.getDepartureWarehouseName()); + // 移除当前的仓库 + groupedByWarehouse.remove(result.getDepartureWarehouseName()); + result.setStartWarehouseNumber(startWarehouseNumber); + temp +=startWarehouseNumber!=null?startWarehouseNumber.getNumber():temp; + /*********************************m目的仓 start********************************/ + String destinationWarehouseName = result.getDestinationWarehouseName(); + WarehouseNumberVO endWarehouseNumber=buildWarehouse(groupedByWarehouse,destinationWarehouseName); + temp +=endWarehouseNumber!=null?endWarehouseNumber.getNumber():temp; + // 计算预约数量 + List end = groupedByWarehouse.get(destinationWarehouseName); + + if(end!=null){ + int resNum = end.stream().filter(t->"20".equals(t.getOrderPackageReservationStatus())).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + result.setDeliveryNum(resNum); + } + + groupedByWarehouse.remove(result.getDestinationWarehouseName()); + result.setEndWarehouseNumber(endWarehouseNumber); + /*********************************m目的仓 end********************************/ + // 判断当前map 中的key长度 + Set keys = groupedByWarehouse.keySet(); + List models = null; + for (String key : keys) { + if(models==null){ + models = new ArrayList<>(); + } + WarehouseNumberVO middleWarehouseNumberVO = buildWarehouse(groupedByWarehouse,key); + models.add(middleWarehouseNumberVO); + temp +=middleWarehouseNumberVO!=null?middleWarehouseNumberVO.getNumber():temp; + } + // 加入中转的数据 + result.setMiddleWarehouseNumber(models); + + // 查询运单的签收数量 + result.setSignNum(byWaybillNo.getSignNum()); + + // 运单状态 + + result.setStatusName(changeStatusName(byWaybillNo.getWaybillStatus())); + + // 计算在途数量 + result.setOnWayCount(result.getTotalCount()-temp); + + + + return result; + } + + private String changeStatusName(String waybillStatus) { + + if(waybillStatus==null){ + waybillStatus=""; + } + + switch (waybillStatus){ + case "20": + return "已入库"; + + case "30": + return "部分中转"; + + case "40": + return "中转"; + + case "50": + return "目的仓部分到达"; + + case "60": + return "目的仓到达"; + + case "70": + return "配送部分装车"; + + case "80": + return "配送装车"; + case "90": + return "部分签收"; + + case "100": + return "已签收"; + default: + return "未知"; + } + + + + + + + } + + + private WarehouseNumberVO buildWarehouse(Map> groupedByWarehouse,String warehouseName){ + + List end = groupedByWarehouse.get(warehouseName); + if(end==null){ + return null; + } + // 获取始发仓的在库数量 + int num = end.stream().filter(t->"20".equals(t.getOrderPackageStatus()) && t.getQuantity()!=0).mapToInt(DistributionParcelListEntity::getQuantity).sum(); + if(num != 0) { + WarehouseNumberVO endWarehouseNumber = new WarehouseNumberVO(); + endWarehouseNumber.setNumber(num); + endWarehouseNumber.setWarehouseName(warehouseName); + + + return endWarehouseNumber; + + } return null; } + + + private R dataOrder(String order) { // 通过订单查询站存单导入时间 - // 导入 + //todo - // return null; diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index 036beca02..aafdbe386 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -1364,7 +1364,7 @@