Przeglądaj źródła

1、模拟流向查询接口
2、模拟SKU服务接口

张昭 3 lat temu
rodzic
commit
eede63d104

+ 20 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/FlowQueryController.java

@@ -2,7 +2,11 @@ package com.abi.qms.platform.controller.console;
 
 import com.abi.platform.Base.BaseResponse;
 import com.abi.qms.platform.dto.req.GetBoxCodeReq;
+import com.abi.qms.platform.dto.req.GetInvisibleCodeReq;
+import com.abi.qms.platform.dto.req.GetStackCodeReq;
 import com.abi.qms.platform.dto.res.GetBoxCodeRes;
+import com.abi.qms.platform.dto.res.GetInvisibleCodeRes;
+import com.abi.qms.platform.dto.res.GetStackCodeRes;
 import com.abi.qms.platform.service.FlowQueryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -34,4 +38,20 @@ public class FlowQueryController {
         return BaseResponse.create(res);
     }
 
+
+    @ApiOperation("隐形码模糊查询")
+    @GetMapping("/invisibleCode/like")
+    public BaseResponse<GetInvisibleCodeRes> invisibleCode (@Validated GetInvisibleCodeReq getInvisibleCodeReq) {
+        GetInvisibleCodeRes res = flowQueryService.invisibleCode(getInvisibleCodeReq);
+        return BaseResponse.create(res);
+    }
+
+    @ApiOperation("垛码查询")
+    @GetMapping("/stackCode")
+    public BaseResponse<GetStackCodeRes> stackCode(@Validated GetStackCodeReq getStackCodeReq) {
+        GetStackCodeRes res = flowQueryService.stackCode(getStackCodeReq);
+        return BaseResponse.create(res);
+    }
+
+
 }

+ 2 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/enums/FlowQueryTypeEnum.java

@@ -18,8 +18,8 @@ import java.util.Set;
 @JsonFormat(shape = JsonFormat.Shape.OBJECT)
 public enum FlowQueryTypeEnum {
     BOX_CODE(1, "箱码查询"),
-    TRAY_CODE(2, "托盘码查询");
-//    INVISIBLE_CODE(3, "隐形码查询")
+    TRAY_CODE(2, "托盘码查询"),
+    INVISIBLE_CODE(3, "隐形码查询");
 
     @EnumValue
     private final Integer code;

+ 23 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/GetInvisibleCodeReq.java

@@ -0,0 +1,23 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+/**
+ * 隐形码查询入参
+ *
+ * @author WeiganCai
+ * @date: 2021-08-16
+ */
+@Data
+@Schema
+public class GetInvisibleCodeReq implements Serializable {
+	@Schema(name = "隐形码")
+	@NotNull(message = "隐形码为空")
+	@Size(min = 20, max = 20, message = "隐形码长度不正确")
+	private String invisibleCode;
+}

+ 21 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/GetStackCodeReq.java

@@ -0,0 +1,21 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 垛码查询入参
+ *
+ * @author WeiganCai
+ * @date: 2021-08-16
+ */
+@Data
+@Schema
+public class GetStackCodeReq implements Serializable {
+	@Schema(name = "垛码")
+	@NotNull(message = "垛码为空")
+	private String stackCode;
+}

+ 39 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetInvisibleCodeRes.java

@@ -0,0 +1,39 @@
+package com.abi.qms.platform.dto.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 隐形码查询出参
+ * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+ *
+ * @author WeiganCai
+ * @date: 2021-08-16
+ */
+@Data
+@Accessors(chain = true)
+@Schema
+public class GetInvisibleCodeRes implements Serializable {
+	@Schema(name = "隐形码查询结果")
+	private List<InvisibleCodeBean> invisibleCodeList;
+
+	@Data
+	@Accessors(chain = true)
+	public static class InvisibleCodeBean {
+		@Schema(name = "隐形码")
+		private String invisibleCode;
+
+		@Schema(name = "箱码")
+		private String boxCode;
+
+		@Schema(name = "堆垛时间")
+		@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+		private LocalDateTime stackTime;
+	}
+}

+ 84 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetStackCodeRes.java

@@ -0,0 +1,84 @@
+package com.abi.qms.platform.dto.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 垛码查询出参
+ * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+ *
+ * @author WeiganCai
+ * @date: 2021-08-16
+ */
+@Data
+@Schema
+public class GetStackCodeRes implements Serializable {
+    @Schema(name = "SKU信息")
+    private SkuBean sku;
+
+    @Schema(name = "流向信息")
+    private List<FlowBean> flowList;
+
+    @Schema(name = "垛信息")
+    private StackBean stack;
+
+    /**
+     * SKU信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class SkuBean implements Serializable {
+        @Schema(name = "品牌编码")
+        private String brandCode;
+
+        @Schema(name = "品牌名称")
+        private String brandName;
+
+        @Schema(name = "SKUId")
+        private String skuId;
+
+        @Schema(name = "SKU名称")
+        private String skuName;
+    }
+
+    /**
+     * 流向信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class FlowBean implements Serializable {
+        @Schema(name = "节点标识")
+        private Long nodeId;
+
+        @Schema(name = "节点名称")
+        private String nodeName;
+
+        @Schema(name = "入库时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime inStorageTime;
+
+        @Schema(name = "出库时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime outStorageTime;
+    }
+
+    /**
+     * 垛信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class StackBean implements Serializable {
+        @Schema(name = "托盘码")
+        private String stackCode;
+
+        @Schema(name = "堆垛时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime StackTime;
+    }
+}

+ 34 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/feign/SkuFeign.java

@@ -0,0 +1,34 @@
+package com.abi.qms.platform.feign;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.springframework.stereotype.Service;
+
+/**
+ * TODO 无法调用其他微服务,模拟SkuFeign
+ * @author WeiganCai
+ * @date: 2021-08-17
+ */
+@Service
+public class SkuFeign {
+
+	public Sku getSkuByCode(String skuCode) {
+		return new Sku()
+				.setSkuId(215L)
+				.setSkuCode(skuCode)
+				.setSkuName("哈尔滨特制超鲜10度610ML1X12纸箱OW瓶装")
+				.setBrandCode("01ABZY")
+				.setBrandName("哈尔滨");
+
+	}
+
+	@Data
+	@Accessors(chain = true)
+	public static class Sku {
+		private Long skuId;
+		private String skuCode;
+		private String skuName;
+		private String brandCode;
+		private String brandName;
+	}
+}

+ 18 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/FlowQueryService.java

@@ -1,7 +1,11 @@
 package com.abi.qms.platform.service;
 
 import com.abi.qms.platform.dto.req.GetBoxCodeReq;
+import com.abi.qms.platform.dto.req.GetInvisibleCodeReq;
+import com.abi.qms.platform.dto.req.GetStackCodeReq;
 import com.abi.qms.platform.dto.res.GetBoxCodeRes;
+import com.abi.qms.platform.dto.res.GetInvisibleCodeRes;
+import com.abi.qms.platform.dto.res.GetStackCodeRes;
 
 /**
  * 箱码垛码查询 Service接口
@@ -22,4 +26,18 @@ public interface FlowQueryService {
      * @return
      */
     GetBoxCodeRes getFlowInfoByBoxCode(String boxCode);
+
+
+
+    /**
+     * 隐形码查询
+     */
+    GetInvisibleCodeRes invisibleCode(GetInvisibleCodeReq getInvisibleCodeReq);
+
+    /**
+     * 垛码查询
+     */
+    GetStackCodeRes stackCode(GetStackCodeReq getStackCodeReq);
+
+
 }

+ 82 - 4
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/FlowQueryServiceImpl.java

@@ -9,7 +9,11 @@ import com.abi.qms.platform.dao.enums.FlowStatusEnum;
 import com.abi.qms.platform.dao.enums.ReqChannelTypeEnum;
 import com.abi.qms.platform.dto.req.AddFlowQueryRecordReq;
 import com.abi.qms.platform.dto.req.GetBoxCodeReq;
+import com.abi.qms.platform.dto.req.GetInvisibleCodeReq;
+import com.abi.qms.platform.dto.req.GetStackCodeReq;
 import com.abi.qms.platform.dto.res.GetBoxCodeRes;
+import com.abi.qms.platform.dto.res.GetInvisibleCodeRes;
+import com.abi.qms.platform.dto.res.GetStackCodeRes;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.UserUtil;
 import com.abi.qms.platform.service.FlowQueryService;
@@ -48,19 +52,23 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     public GetBoxCodeRes boxCode(GetBoxCodeReq req) {
         Integer queryType = req.getQueryType();
         GetBoxCodeRes res = null;
-        //箱码查询
+
         if (FlowQueryTypeEnum.BOX_CODE.is(queryType)) {
+            // 箱码(明码)查询
+            String boxCode = req.getBoxCode();
+            res = this.getFlowInfoByBoxCode(boxCode);
+        } else if (FlowQueryTypeEnum.INVISIBLE_CODE.is(queryType)) {
+            // 箱码(隐形码)查询
             String boxCode = req.getBoxCode();
             res = this.getFlowInfoByBoxCode(boxCode);
         }
 
-        AssertUtil.isNull(res, "为查询到流向信息!");
+        AssertUtil.isNull(res, "查询到流向信息!");
         //保存查询记录
         this.saveQueryRecord(res, req);
         return res;
     }
 
-
     /**
      * 查询流向信息
      *
@@ -149,6 +157,73 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     }
 
 
+
+    /**
+     * 隐形码查询
+     * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+     */
+    @Override
+    public GetInvisibleCodeRes invisibleCode(GetInvisibleCodeReq req) {
+        String invisibleCode = req.getInvisibleCode();
+        List<GetInvisibleCodeRes.InvisibleCodeBean> invisibleCodeList = new ArrayList<>();
+        GetInvisibleCodeRes.InvisibleCodeBean invisibleCodeBean;
+        // 模拟10条数据
+        for (int i = 0; i < 10; i++) {
+            invisibleCodeBean = new GetInvisibleCodeRes.InvisibleCodeBean()
+                    .setBoxCode(invisibleCode.replace("_", String.valueOf(i)))
+                    .setInvisibleCode(invisibleCode.replace("_", String.valueOf(i)))
+                    .setStackTime(LocalDateTime.now());
+            invisibleCodeList.add(invisibleCodeBean);
+        }
+        return new GetInvisibleCodeRes().setInvisibleCodeList(invisibleCodeList);
+    }
+
+    /**
+     * 垛码查询
+     * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+     */
+    @Override
+    public GetStackCodeRes stackCode(GetStackCodeReq req) {
+        GetStackCodeRes res = new GetStackCodeRes();
+
+        GetStackCodeRes.SkuBean sku = new GetStackCodeRes.SkuBean()
+                .setBrandCode("01AAHF")
+                .setBrandName("百威")
+                .setSkuId("000000000000025000")
+                .setSkuName("百威9.7度330ML4X6半托纸箱听装(机械改包)");
+
+        List flowList = new LinkedList();
+        GetStackCodeRes.FlowBean flow = new GetStackCodeRes.FlowBean()
+                .setNodeId(8903L)
+                .setNodeName("一级经销商")
+                .setInStorageTime(LocalDateTime.of(2020, 12, 24, 11, 12, 38))
+                .setOutStorageTime(LocalDateTime.of(2020, 12, 24, 15, 12, 33));
+        flowList.add(flow);
+
+        flow = new GetStackCodeRes.FlowBean()
+                .setNodeId(8902L)
+                .setNodeName("XXXX-上海吴泾DC")
+                .setInStorageTime(LocalDateTime.of(2020, 12, 20, 9, 31, 33))
+                .setOutStorageTime(LocalDateTime.of(2020, 12, 20, 9, 31, 33));
+
+        flowList.add(flow);
+        Collections.reverse(flowList);
+
+        GetStackCodeRes.StackBean stack = new GetStackCodeRes.StackBean()
+                .setStackCode(req.getStackCode())
+                .setStackTime(LocalDateTime.now());
+
+        res.setSku(sku);
+        res.setFlowList(flowList);
+        res.setStack(stack);
+
+        return res;
+    }
+
+
+
+
+
     /**
      * 保存查询记录
      *
@@ -169,7 +244,10 @@ public class FlowQueryServiceImpl implements FlowQueryService {
 
             //查询类型
             Integer queryType = req.getQueryType();
-            AddFlowQueryRecordReq addReq = new AddFlowQueryRecordReq(flowStatus.getCode(), queryType);
+            AddFlowQueryRecordReq addReq = new AddFlowQueryRecordReq();
+            addReq.setFlowStatus(flowStatus.getCode());
+            addReq.setQueryType(queryType);
+
 
             //  箱码 查询类型为箱码时必传
             addReq.setBoxCode(req.getBoxCode());