2 Revīzijas 76ec3c82d9 ... 0304dd7828

Autors SHA1 Ziņojums Datums
  张昭 0304dd7828 Merge remote-tracking branch 'origin/feature/1.0.0' into feature/1.0.0 3 gadi atpakaļ
  张昭 31097ecf36 模拟流向查询接口更改 3 gadi atpakaļ

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

@@ -5,6 +5,7 @@ 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.GetFlowInfoRes;
 import com.abi.qms.platform.dto.res.GetInvisibleCodeRes;
 import com.abi.qms.platform.dto.res.GetStackCodeRes;
 import com.abi.qms.platform.service.FlowQueryService;
@@ -31,10 +32,10 @@ public class FlowQueryController {
     @Autowired
     private FlowQueryService flowQueryService;
 
-    @ApiOperation("箱码查询")
-    @GetMapping("/boxCode")
-    public BaseResponse<GetBoxCodeRes> boxCode (@Validated GetBoxCodeReq getBoxCodeReq) {
-        GetBoxCodeRes res = flowQueryService.boxCode(getBoxCodeReq);
+    @ApiOperation("箱码垛码查询")
+    @GetMapping()
+    public BaseResponse<GetFlowInfoRes> boxCode (@Validated GetBoxCodeReq getBoxCodeReq) {
+        GetFlowInfoRes res = flowQueryService.queryFlow(getBoxCodeReq);
         return BaseResponse.create(res);
     }
 
@@ -45,12 +46,12 @@ public class FlowQueryController {
         return BaseResponse.create(res);
     }
 
-    @ApiOperation("垛码查询")
-    @GetMapping("/stackCode")
-    public BaseResponse<GetStackCodeRes> stackCode(@Validated GetStackCodeReq getStackCodeReq) {
-        GetStackCodeRes res = flowQueryService.stackCode(getStackCodeReq);
-        return BaseResponse.create(res);
-    }
+    //@ApiOperation("垛码查询")
+    //@GetMapping("/stackCode")
+    //public BaseResponse<GetStackCodeRes> stackCode(@Validated GetStackCodeReq getStackCodeReq) {
+    //    GetStackCodeRes res = flowQueryService.stackCode(getStackCodeReq);
+    //    return BaseResponse.create(res);
+    //}
 
 
 }

+ 3 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/InspectionCaseFlowMapper.java

@@ -1,6 +1,7 @@
 package com.abi.qms.platform.dao.mapper;
 
 import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
+import com.abi.qms.platform.dto.res.GetCaseInfoByBoxCodeRes;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -33,4 +34,6 @@ public interface InspectionCaseFlowMapper extends BaseMapper<InspectionCaseFlow>
      * @return
      */
     List<InspectionCaseFlow> getList(@Param("caseId") Long id);
+
+    GetCaseInfoByBoxCodeRes getCaseInfoByBoxCode(@Param("code") String code);
 }

+ 2 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/GetBoxCodeReq.java

@@ -26,9 +26,9 @@ public class GetBoxCodeReq implements Serializable {
     @NotNull(message = "查询类型为空")
     private Integer queryType;
 
-    @Schema(name = "箱码")
+    @Schema(name = "查询内容 -对应查询类型")
     @NotNull(message = "箱码为空")
-    private String boxCode;
+    private String inquireCode;
 
 
 }

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

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dto.res;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author: ZhangZhao
+ * @date: 2021/8/23 17:23
+ * @description: 根据箱码查询关联案件 出参
+ */
+@Data
+@ApiModel
+@NoArgsConstructor
+public class GetCaseInfoByBoxCodeRes {
+
+    /**
+     * 案件ID
+     */
+    @ApiModelProperty(value = "ID")
+    private String id;
+
+    /**
+     * 案件编号
+     */
+    @ApiModelProperty(value = "案件编号")
+    private String caseNumber;
+
+    /**
+     * 案件名称
+     */
+    @ApiModelProperty(value = "案件名称")
+    private String caseName;
+
+}

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

@@ -0,0 +1,154 @@
+package com.abi.qms.platform.dto.res;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+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;
+
+/**
+ * @author: ZhangZhao
+ * @date: 2021/8/23 16:57
+ * @description: TODO
+ */
+@Data
+@ApiModel
+public class GetFlowInfoRes {
+
+    @Schema(name = "SKU信息")
+    private SkuBean sku;
+
+    @Schema(name = "案件信息")
+    private InspectionCaseBean inspectionCase;
+
+    @Schema(name = "流向信息")
+    private List<FlowBean> flowList;
+
+    @Schema(name = "箱垛信息")
+    private BoxStackBean boxStack;
+
+    @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;
+
+        @Schema(name = "生产批次")
+        private String productionBatch;
+
+        @Schema(name = "生产日期")
+        @JsonFormat(pattern = "yyyy-MM-dd")
+        private LocalDateTime productionTime;
+    }
+
+    /**
+     * 案件信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class InspectionCaseBean implements Serializable {
+        @Schema(name = "案件编号")
+        private String caseNumber;
+
+        @Schema(name = "案件名称")
+        private String caseName;
+    }
+
+    /**
+     * 流向信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class FlowBean implements Serializable {
+        @Schema(name = "节点标识")
+        private Long nodeId;
+
+        @Schema(name = "节点名称")
+        private String nodeName;
+
+        @Schema(name = "节点状态")
+        private Integer nodeStatus;
+
+        @Schema(name = "异常类型 0-无异常 1-流入异常 2-流出异常")
+        private Integer abnormalType = 0;
+
+        @Schema(name = "是否拆垛")
+        private Integer isSplit;
+
+        @Schema(name = "拆垛托盘码")
+        private String splitStackCode;
+
+        @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 BoxStackBean implements Serializable {
+        @Schema(name = "箱码")
+        private String boxCode;
+
+        @Schema(name = "隐形码")
+        private String invisibleCode;
+
+        @Schema(name = "原始托盘码")
+        private String originalStackCode;
+
+        @Schema(name = "原始堆垛时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime originalStackTime;
+
+        @Schema(name = "最新托盘码")
+        private String newestStackCode;
+
+        @Schema(name = "最新堆垛时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime newestStackTime;
+    }
+
+
+
+    /**
+     * 垛信息
+     */
+    @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;
+    }
+
+}

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

@@ -10,36 +10,33 @@ import com.abi.qms.platform.dto.res.*;
  * @date 2021-08-02
  */
 public interface FlowQueryService {
+
+
     /**
      * 流向查询
      */
-    GetBoxCodeRes boxCode(GetBoxCodeReq getBoxCodeReq);
-
-
+    GetFlowInfoRes queryFlow(GetBoxCodeReq getBoxCodeReq);
     /**
      * 箱码查询
      * @param boxCode 箱码
      * @return
      */
-    GetBoxCodeRes getFlowInfoByBoxCode(String boxCode);
+    GetFlowInfoRes getFlowInfoByBoxCode(String boxCode);
 
     /**
      * 隐形码
      * @param invisibleCode 隐形码
      * @return
      */
-    GetBoxCodeRes getFlowInfoByInvisibleCode(String invisibleCode);
+    GetFlowInfoRes getFlowInfoByInvisibleCode(String invisibleCode);
+
 
+    GetFlowInfoRes  getFlowInfoByStackCode(String stackCode);
     /**
      * 隐形码查询
      */
     GetInvisibleCodeRes invisibleCode(GetInvisibleCodeReq getInvisibleCodeReq);
 
-    /**
-     * 垛码查询
-     */
-    GetStackCodeRes stackCode(GetStackCodeReq getStackCodeReq);
-
 
     /**
      * 微信箱码查询
@@ -55,4 +52,6 @@ public interface FlowQueryService {
      * 微信垛码查询
      */
     WxGetStackCodeRes wxStackCode(WxGetStackCodeReq req);
+
+
 }

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

@@ -45,6 +45,9 @@ public interface IInspectionCaseService {
     void removeInspectionCase(Long[] ids);
 
 
+    GetCaseInfoByBoxCodeRes getCaseInfoByBoxCode(final String boxCode);
+
+
     /**
      * 获取案件详情信息
      *
@@ -76,6 +79,7 @@ public interface IInspectionCaseService {
      */
     GetCaseBoxCodeListRes getBoxCodeListByCaseId(final Long caseId);
 
+
     /**
      * 导出
      *

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

@@ -14,6 +14,7 @@ import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.UserUtil;
 import com.abi.qms.platform.service.FlowQueryService;
 import com.abi.qms.platform.service.IFlowQueryRecordService;
+import com.abi.qms.platform.service.IInspectionCaseService;
 import com.abi.task.common.utils.PojoConverterUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,11 +38,16 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     @Autowired
     private IFlowQueryRecordService flowQueryRecordService;
 
+    @Autowired
+    private IInspectionCaseService caseService;
+
     @Autowired
     private UserUtil userUtil;
 
 
-    private  static  List<GetBoxCodeRes> boxCodeResList=new ArrayList<>();
+    private static List<GetBoxCodeRes> boxCodeResList = new ArrayList<>();
+
+    private static List<GetStackCodeRes> StackCodeResList = new ArrayList<>();
 
     static {
         GetBoxCodeRes res1 = new GetBoxCodeRes();
@@ -111,6 +117,42 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         res3.setFlowList(flowList3);
         res3.setBoxStack(boxStack3);
         boxCodeResList.add(res3);
+
+        //======================  垛码信息  ===================
+
+        GetStackCodeRes resA = new GetStackCodeRes();
+
+        GetStackCodeRes.SkuBean skuA = new GetStackCodeRes.SkuBean()
+                .setBrandCode("01AAHF")
+                .setBrandName("百威")
+                .setSkuId("000000000000025000")
+                .setSkuName("百威9.7度330ML4X6半托纸箱听装(机械改包)");
+
+        List flowListA = 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));
+        flowListA.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));
+
+        flowListA.add(flow);
+
+        GetStackCodeRes.StackBean stackA = new GetStackCodeRes.StackBean()
+                .setStackCode("2000300040005000")
+                .setStackTime(LocalDateTime.now());
+
+        resA.setSku(skuA);
+        resA.setFlowList(flowListA);
+        resA.setStack(stackA);
+        StackCodeResList.add(resA);
+
     }
 
     private static List<GetBoxCodeRes.FlowBean> getflowList() {
@@ -166,27 +208,27 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     }
 
 
-
-
     /**
      * 箱码查询
      * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
      */
     @Override
-    public GetBoxCodeRes boxCode(GetBoxCodeReq req) {
+    public GetFlowInfoRes queryFlow(GetBoxCodeReq req) {
         Integer queryType = req.getQueryType();
-        GetBoxCodeRes res = null;
+        GetFlowInfoRes res = null;
+        //查询内容
+        String inquireCode = req.getInquireCode();
 
         if (FlowQueryTypeEnum.BOX_CODE.is(queryType)) {
-            // 箱码(明码)查询
-            String boxCode = req.getBoxCode();
-            res = this.getFlowInfoByBoxCode(boxCode);
+            //箱码(明码)查询
+            res = this.getFlowInfoByBoxCode(inquireCode);
         } else if (FlowQueryTypeEnum.INVISIBLE_CODE.is(queryType)) {
             // 箱码(隐形码)查询
-            String boxCode = req.getBoxCode();
-            res = this.getFlowInfoByInvisibleCode(boxCode);
+            res = this.getFlowInfoByInvisibleCode(inquireCode);
+        } else if (FlowQueryTypeEnum.TRAY_CODE.is(queryType)) {
+            // 剁码查询
+            res = this.getFlowInfoByStackCode(inquireCode);
         }
-
         AssertUtil.isNull(res, "未查询到流向信息!");
         //保存查询记录
         this.saveQueryRecord(res, req);
@@ -200,13 +242,33 @@ public class FlowQueryServiceImpl implements FlowQueryService {
      * @return
      */
     @Override
-    public GetBoxCodeRes getFlowInfoByBoxCode(String boxCode) {
-        GetBoxCodeRes getBoxCodeRes=null;
+    public GetFlowInfoRes getFlowInfoByBoxCode(String boxCode) {
+        GetFlowInfoRes flowInfoRes = null;
         List<GetBoxCodeRes> collect = boxCodeResList.stream().filter(s -> s.getBoxStack().getBoxCode().equals(boxCode)).collect(Collectors.toList());
-        if(CollectionUtil.isNotEmpty(collect)){
-             getBoxCodeRes = collect.get(0);
+        if (CollectionUtil.isEmpty(collect)) {
+            return null;
         }
-        return getBoxCodeRes;
+        GetBoxCodeRes getBoxCodeRes = collect.get(0);
+
+        flowInfoRes = new GetFlowInfoRes();
+        //SKU
+        GetFlowInfoRes.SkuBean skuBean = new GetFlowInfoRes.SkuBean();
+        BeanUtil.copyProperties(getBoxCodeRes.getSku(), skuBean);
+        flowInfoRes.setSku(skuBean);
+
+        //流向 信息
+        List<GetFlowInfoRes.FlowBean> flowBeanList = PojoConverterUtils.copyList(getBoxCodeRes.getFlowList(), GetFlowInfoRes.FlowBean.class);
+        flowInfoRes.setFlowList(flowBeanList);
+
+        //箱垛信息
+        GetFlowInfoRes.BoxStackBean boxStackBean = new GetFlowInfoRes.BoxStackBean();
+        BeanUtil.copyProperties(getBoxCodeRes.getBoxStack(), boxStackBean);
+        flowInfoRes.setBoxStack(boxStackBean);
+
+        //案件信息
+        flowInfoRes.setInspectionCase(this.getCaseInfoByBoxCode(boxStackBean.getBoxCode()));
+
+        return flowInfoRes;
     }
 
 
@@ -217,16 +279,79 @@ public class FlowQueryServiceImpl implements FlowQueryService {
      * @return
      */
     @Override
-    public GetBoxCodeRes getFlowInfoByInvisibleCode(String invisibleCode) {
-        GetBoxCodeRes getBoxCodeRes=null;
+    public GetFlowInfoRes getFlowInfoByInvisibleCode(String invisibleCode) {
+        GetFlowInfoRes flowInfoRes = null;
         List<GetBoxCodeRes> collect = boxCodeResList.stream().filter(s -> s.getBoxStack().getInvisibleCode().equals(invisibleCode)).collect(Collectors.toList());
-        if(CollectionUtil.isNotEmpty(collect)){
-            getBoxCodeRes = collect.get(0);
+        if (CollectionUtil.isEmpty(collect)) {
+            return null;
         }
-        return getBoxCodeRes;
+
+        GetBoxCodeRes getBoxCodeRes = collect.get(0);
+
+        flowInfoRes = new GetFlowInfoRes();
+        //SKU
+        GetFlowInfoRes.SkuBean skuBean = new GetFlowInfoRes.SkuBean();
+        BeanUtil.copyProperties(getBoxCodeRes.getSku(), skuBean);
+        flowInfoRes.setSku(skuBean);
+
+        //流向 信息
+        List<GetFlowInfoRes.FlowBean> flowBeanList = PojoConverterUtils.copyList(getBoxCodeRes.getFlowList(), GetFlowInfoRes.FlowBean.class);
+        flowInfoRes.setFlowList(flowBeanList);
+
+        //箱垛信息
+        GetFlowInfoRes.BoxStackBean boxStackBean = new GetFlowInfoRes.BoxStackBean();
+        BeanUtil.copyProperties(getBoxCodeRes.getBoxStack(), boxStackBean);
+        flowInfoRes.setBoxStack(boxStackBean);
+
+        //案件信息
+        flowInfoRes.setInspectionCase(this.getCaseInfoByBoxCode(boxStackBean.getBoxCode()));
+        return flowInfoRes;
+    }
+
+    /**
+     * 根据箱码查询关联案件信息
+     *
+     * @param boxCode 箱码
+     * @return 案件信息
+     */
+    private GetFlowInfoRes.InspectionCaseBean getCaseInfoByBoxCode(String boxCode) {
+        GetCaseInfoByBoxCodeRes caseInfoByBoxCode = caseService.getCaseInfoByBoxCode(boxCode);
+        GetFlowInfoRes.InspectionCaseBean inspectionCaseBean = new GetFlowInfoRes.InspectionCaseBean();
+        BeanUtil.copyProperties(caseInfoByBoxCode, inspectionCaseBean);
+        return inspectionCaseBean;
     }
 
 
+    /**
+     * 垛码查询
+     * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+     */
+    @Override
+    public GetFlowInfoRes getFlowInfoByStackCode(String stackCode) {
+        GetFlowInfoRes flowInfoRes = null;
+        List<GetStackCodeRes> collect = StackCodeResList.stream().filter(s -> s.getStack().getStackCode().equals(stackCode)).collect(Collectors.toList());
+        if (CollectionUtil.isEmpty(collect)) {
+            return null;
+        }
+
+        GetStackCodeRes getStackCodeRes = collect.get(0);
+
+        flowInfoRes = new GetFlowInfoRes();
+        //SKU
+        GetFlowInfoRes.SkuBean skuBean = new GetFlowInfoRes.SkuBean();
+        BeanUtil.copyProperties(getStackCodeRes.getSku(), skuBean);
+        flowInfoRes.setSku(skuBean);
+
+        //流向 信息
+        List<GetFlowInfoRes.FlowBean> flowBeanList = PojoConverterUtils.copyList(getStackCodeRes.getFlowList(), GetFlowInfoRes.FlowBean.class);
+        flowInfoRes.setFlowList(flowBeanList);
+
+        //垛信息
+        GetFlowInfoRes.StackBean stackBean = new GetFlowInfoRes.StackBean();
+        BeanUtil.copyProperties(getStackCodeRes.getStack(), stackBean);
+        flowInfoRes.setStack(stackBean);
+        return flowInfoRes;
+    }
 
 
     /**
@@ -249,47 +374,6 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         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;
-    }
 
     /**
      * 微信箱码查询
@@ -297,9 +381,8 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     @Override
     public WxGetBoxCodeRes wxBoxCode(WxGetBoxCodeReq req) {
         // TODO 处理逻辑同console端,待流向查询接口完成后修改
-        GetBoxCodeReq boxCodeReq = PojoConverterUtils.copy(req, GetBoxCodeReq.class);
-        GetBoxCodeRes boxCodeRes = this.boxCode(boxCodeReq);
-        return PojoConverterUtils.copy(boxCodeRes, WxGetBoxCodeRes.class);
+        GetFlowInfoRes flowInfoByBoxCode = this.getFlowInfoByBoxCode(req.getBoxCode());
+        return PojoConverterUtils.copy(flowInfoByBoxCode, WxGetBoxCodeRes.class);
     }
 
 
@@ -309,9 +392,8 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     @Override
     public WxGetInvisibleCodeRes WxInvisibleCode(WxGetInvisibleCodeReq req) {
         // TODO 处理逻辑同console端,待流向查询接口完成后修改
-        GetInvisibleCodeReq invisibleCodeReq = PojoConverterUtils.copy(req, GetInvisibleCodeReq.class);
-        GetInvisibleCodeRes invisibleCodeRes = this.invisibleCode(invisibleCodeReq);
-        return PojoConverterUtils.copy(invisibleCodeRes, WxGetInvisibleCodeRes.class);
+        GetFlowInfoRes flowInfoByInvisibleCode = this.getFlowInfoByInvisibleCode(req.getInvisibleCode());
+        return PojoConverterUtils.copy(flowInfoByInvisibleCode, WxGetInvisibleCodeRes.class);
     }
 
     /**
@@ -320,46 +402,51 @@ public class FlowQueryServiceImpl implements FlowQueryService {
     @Override
     public WxGetStackCodeRes wxStackCode(WxGetStackCodeReq req) {
         // TODO 处理逻辑同console端,待流向查询接口完成后修改
-        GetStackCodeReq stackCodeReq = PojoConverterUtils.copy(req, GetStackCodeReq.class);
-        GetStackCodeRes stackCodeRes = this.stackCode(stackCodeReq);
+        GetFlowInfoRes stackCodeRes = this.getFlowInfoByStackCode(req.getStackCode());
         return PojoConverterUtils.copy(stackCodeRes, WxGetStackCodeRes.class);
     }
 
+
     /**
      * 保存查询记录
      *
      * @param res 查询结果
      * @param req 查询请求
      */
-    private void saveQueryRecord(GetBoxCodeRes res, GetBoxCodeReq req) {
+    private void saveQueryRecord(GetFlowInfoRes res, GetBoxCodeReq req) {
         try {
-
+            //查询类型
+            Integer queryType = req.getQueryType();
             //判断流向状态
-            Map<Integer, GetBoxCodeRes.FlowBean> abnormalNodeMap = res.getFlowList()
-                    .stream()
-                    .filter(s -> !(s.getNodeStatus().equals(1)))
-                    .collect(Collectors.toMap(GetBoxCodeRes.FlowBean::getAbnormalType, flowBean -> flowBean));
-
+            Map<Integer, GetFlowInfoRes.FlowBean> abnormalNodeMap = new HashMap<>();
+            if (!FlowQueryTypeEnum.TRAY_CODE.is(req.getQueryType())) {
+                abnormalNodeMap = res.getFlowList()
+                        .stream()
+                        .filter(s -> !(s.getNodeStatus().equals(1)))
+                        .collect(Collectors.toMap(GetFlowInfoRes.FlowBean::getAbnormalType, flowBean -> flowBean));
+            }
 
-            FlowStatusEnum flowStatus = MapUtil.isEmpty(abnormalNodeMap) ? FlowStatusEnum.ABNORMAL : FlowStatusEnum.NORMAL;
+            FlowStatusEnum flowStatus = MapUtil.isEmpty(abnormalNodeMap) ? FlowStatusEnum.NORMAL : FlowStatusEnum.ABNORMAL;
 
-            //查询类型
-            Integer queryType = req.getQueryType();
             AddFlowQueryRecordReq addReq = new AddFlowQueryRecordReq();
             addReq.setFlowStatus(flowStatus.getCode());
             addReq.setQueryType(queryType);
 
 
             //  箱码 查询类型为箱码时必传
-            addReq.setBoxCode(req.getBoxCode());
-            addReq.setTrayCode("");
+            if (FlowQueryTypeEnum.TRAY_CODE.is(req.getQueryType())) {
+                addReq.setTrayCode(res.getStack().getStackCode());
+            } else {
+                addReq.setBoxCode(res.getBoxStack().getBoxCode());
+            }
+
 
             //品牌
             addReq.setBrandCode(res.getSku().getBrandCode());
             addReq.setBrandName(res.getSku().getBrandName());
 
             //sku
-            GetBoxCodeRes.SkuBean sku = res.getSku();
+            GetFlowInfoRes.SkuBean sku = res.getSku();
             addReq.setSkuCode(sku.getSkuId());
             addReq.setProductionBatch(sku.getProductionBatch());
             addReq.setProductionTime(sku.getProductionTime());
@@ -372,7 +459,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
             addReq.setQueryAddress("");
 
             //abnormalNodeIn
-            GetBoxCodeRes.FlowBean abnormalNodeIn = abnormalNodeMap.get(1);
+            GetFlowInfoRes.FlowBean abnormalNodeIn = abnormalNodeMap.get(1);
             if (Objects.nonNull(abnormalNodeIn)) {
                 addReq.setAbnormalInNodeCode(abnormalNodeIn.getNodeId());
                 addReq.setAbnormalInNodeName(abnormalNodeIn.getNodeName());
@@ -380,19 +467,19 @@ public class FlowQueryServiceImpl implements FlowQueryService {
 
 
             //abnormalNodeOut
-            GetBoxCodeRes.FlowBean abnormalNodeOut = abnormalNodeMap.get(2);
+            GetFlowInfoRes.FlowBean abnormalNodeOut = abnormalNodeMap.get(2);
             if (Objects.nonNull(abnormalNodeOut)) {
                 addReq.setAbnormalOutNodeCode(abnormalNodeOut.getNodeId());
                 addReq.setAbnormalOutNodeName(abnormalNodeOut.getNodeName());
             }
             //箱垛信息
-            GetBoxCodeRes.BoxStackBean boxStack = res.getBoxStack();
+            GetFlowInfoRes.BoxStackBean boxStack = res.getBoxStack();
             AddFlowQueryRecordReq.BoxStackBean boxStackBean = new AddFlowQueryRecordReq.BoxStackBean();
             BeanUtil.copyProperties(boxStack, boxStackBean);
             addReq.setBoxStackInfo(boxStackBean);
 
             //流向信息列表
-            List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
+            List<GetFlowInfoRes.FlowBean> flowList = res.getFlowList();
             List<AddFlowQueryRecordReq.FlowBean> flowBeans = PojoConverterUtils.copyList(flowList, AddFlowQueryRecordReq.FlowBean.class);
             addReq.setFlowList(flowBeans);
 

+ 35 - 26
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/InspectionCaseServiceImpl.java

@@ -91,11 +91,11 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         List<AddInspectionCaseReq.BoxCode> involvedBoxCodes = addReq.getInvolvedBoxCodes();
         List<String> boxCodeStrList = involvedBoxCodes.stream().map(AddInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
         //查询箱码流向信息
-        List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
+        List<GetFlowInfoRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
         //校验箱码信息
         this.validatedBoxCode(flowInfoByBoxCodeList, addReq.getSkuCode());
         //流向信息
-        List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
+        List<GetFlowInfoRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
 
         //============案件编号============
         String caseNumber = addReq.getCaseNumber();
@@ -122,18 +122,18 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         InspectionCase inspectionCase = new InspectionCase();
         BeanUtil.copyProperties(addReq, inspectionCase);
         //流出经销商 从 flowInfo 中取出
-        GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
+        GetFlowInfoRes.FlowBean outAgencyFlowBean = flowList.stream()
                 .filter(s -> s.getAbnormalType().equals(2))
-                .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
+                .min(Comparator.comparing(GetFlowInfoRes.FlowBean::getOutStorageTime))
                 .orElseThrow(() -> new BusinessException("没有流出异常节点"));
 
         inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
         inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
 
         // 设置流入 经销商 从 flowInfo 中取出
-        GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
+        GetFlowInfoRes.FlowBean inAgencyflowBean = flowList.stream()
                 .filter(s -> s.getAbnormalType().equals(1))
-                .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
+                .max(Comparator.comparing(GetFlowInfoRes.FlowBean::getInStorageTime))
                 .orElseThrow(() -> new BusinessException("没有流入异常节点"));
 
         inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
@@ -247,26 +247,26 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         List<EditInspectionCaseReq.BoxCode> involvedBoxCodes = editReq.getInvolvedBoxCodes();
         List<String> boxCodeStrList = involvedBoxCodes.stream().map(EditInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
         //查询箱码流向信息
-        List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
+        List<GetFlowInfoRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
         //校验箱码信息
         this.validatedBoxCode(flowInfoByBoxCodeList, inspectionCase.getSkuCode());
         //流向信息
-        List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
+        List<GetFlowInfoRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
 
         //============修改案件信息============
         //流出经销商 从 flowInfo 中取出
-        GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
+        GetFlowInfoRes.FlowBean outAgencyFlowBean = flowList.stream()
                 .filter(s -> s.getAbnormalType().equals(2))
-                .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
+                .min(Comparator.comparing(GetFlowInfoRes.FlowBean::getOutStorageTime))
                 .orElseThrow(() -> new BusinessException("没有流出异常节点"));
 
         inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
         inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
 
         // 设置流入 经销商 从 flowInfo 中取出
-        GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
+        GetFlowInfoRes.FlowBean inAgencyflowBean = flowList.stream()
                 .filter(s -> s.getAbnormalType().equals(1))
-                .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
+                .max(Comparator.comparing(GetFlowInfoRes.FlowBean::getInStorageTime))
                 .orElseThrow(() -> new BusinessException("没有流入异常节点"));
 
         inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
@@ -334,6 +334,15 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
 
     }
 
+
+
+    @Override
+    public GetCaseInfoByBoxCodeRes getCaseInfoByBoxCode(final  String code){
+        AssertUtil.isMeets(code, StrUtil::isNotBlank,"根据箱码查询 箱码不能为空!");
+        return inspectionCaseFlowMapper.getCaseInfoByBoxCode(code);
+    }
+
+
     /**
      * 获取案件详情信息
      *
@@ -414,17 +423,17 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         String boxCode = req.getBoxCode();
         //查询箱码信息
         List<String> boxCodeList = Collections.singletonList(boxCode);
-        List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeList);
-        GetBoxCodeRes getBoxCodeRes = flowInfoByBoxCodeList.get(0);
+        List<GetFlowInfoRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeList);
+        GetFlowInfoRes flowInfoRes = flowInfoByBoxCodeList.get(0);
 
-        List<GetBoxCodeRes.FlowBean> reqFlowList = getBoxCodeRes.getFlowList();
+        List<GetFlowInfoRes.FlowBean> reqFlowList = flowInfoRes.getFlowList();
         //验证指定案件是否存在
         InspectionCase inspectionCase = inspectionCaseMapper.selectById(caseId);
         AssertUtil.isNull(inspectionCase, "指定案件不存在或已被删除!");
 
         //验证SKU是否一致
         String skuCode = inspectionCase.getSkuCode();
-        AssertUtil.isMeets(getBoxCodeRes.getSku().getSkuId(), s -> StrUtil.equals(s, skuCode), "当前箱码与指定案件SKU不一致!");
+        AssertUtil.isMeets(flowInfoRes.getSku().getSkuId(), s -> StrUtil.equals(s, skuCode), "当前箱码与指定案件SKU不一致!");
 
         //验证当前箱码是否已经存在
         QueryWrapper<InspectionCaseBoxCode> boxCodeQW = new QueryWrapper<>();
@@ -443,7 +452,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
                 .collect(Collectors.toList());
         //请求流向节点
         List<Long> reqNodeIds = reqFlowList.stream()
-                .map(GetBoxCodeRes.FlowBean::getNodeId)
+                .map(GetFlowInfoRes.FlowBean::getNodeId)
                 .collect(Collectors.toList());
 
 
@@ -463,7 +472,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         //请求流向最小出库时间
         LocalDateTime resOutStorageTime = reqFlowList.stream()
                 .filter(s -> Objects.nonNull(s.getOutStorageTime()))
-                .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
+                .min(Comparator.comparing(GetFlowInfoRes.FlowBean::getOutStorageTime))
                 .get()
                 .getOutStorageTime();
 
@@ -557,10 +566,10 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
      * @param boxCodeList 箱码列表
      * @return 对应流向信息列表
      */
-    private List<GetBoxCodeRes> getFlowInfoByBoxCodeList(List<String> boxCodeList) {
-        List<GetBoxCodeRes> getBoxCodeResList = new ArrayList<>();
+    private List<GetFlowInfoRes> getFlowInfoByBoxCodeList(List<String> boxCodeList) {
+        List<GetFlowInfoRes> getBoxCodeResList = new ArrayList<>();
         boxCodeList.forEach(s -> {
-            GetBoxCodeRes res = flowQueryService.getFlowInfoByBoxCode(s);
+            GetFlowInfoRes res = flowQueryService.getFlowInfoByBoxCode(s);
             AssertUtil.isNull(res, "失败!箱码:" + s + ",失败原因:未查询到此箱码信息!");
             getBoxCodeResList.add(res);
         });
@@ -577,7 +586,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
      * @param boxCodeResList 箱码信息
      * @return 流向信息
      */
-    private void validatedBoxCode(List<GetBoxCodeRes> boxCodeResList, String skuCode) {
+    private void validatedBoxCode(List<GetFlowInfoRes> boxCodeResList, String skuCode) {
 
         List<String> skuErrBoxCode = new ArrayList<>();
         List<String> flowErrBoxCode = new ArrayList<>();
@@ -585,7 +594,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         Set<LocalDateTime> outStorageTimeSet = new HashSet<LocalDateTime>();
         List<Long> firstFlowNodeIdList = new ArrayList<>();
 
-        for (GetBoxCodeRes res : boxCodeResList) {
+        for (GetFlowInfoRes res : boxCodeResList) {
 
             //箱码
             String boxCode = res.getBoxStack().getBoxCode();
@@ -598,12 +607,12 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
 
             //判断流向是否一致
             //获取当前流向信息
-            List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
-            LocalDateTime outStorageTime = flowList.stream().filter(s -> Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
+            List<GetFlowInfoRes.FlowBean> flowList = res.getFlowList();
+            LocalDateTime outStorageTime = flowList.stream().filter(s -> Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetFlowInfoRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
             boolean outStorageTimeAdd = outStorageTimeSet.add(outStorageTime);
 
             //获取当前所以流向节点ID
-            List<Long> nodeIds = flowList.stream().map(GetBoxCodeRes.FlowBean::getNodeId).collect(Collectors.toList());
+            List<Long> nodeIds = flowList.stream().map(GetFlowInfoRes.FlowBean::getNodeId).collect(Collectors.toList());
             //如果firstFlowNodeIdList 为空 则赋值
             if (CollectionUtil.isEmpty(firstFlowNodeIdList)) {
                 firstFlowNodeIdList.addAll(nodeIds);

+ 20 - 0
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/InspectionCaseFlowMapper.xml

@@ -98,4 +98,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
+    <resultMap type="com.abi.qms.platform.dto.res.GetCaseInfoByBoxCodeRes" id="GetCaseInfoByBoxCodeRes">
+        <result property="id" column="id"/>
+        <result property="caseName" column="case_name"/>
+        <result property="caseNumber" column="case_number"/>
+    </resultMap>
+
+    <select id="getCaseInfoByBoxCode" resultMap="GetCaseInfoByBoxCodeRes" parameterType="java.lang.String">
+        SELECT
+            ic.id,
+            ic.case_name,
+            ic.case_number
+        FROM
+            inspection_case_box_code AS icbc
+            LEFT JOIN inspection_case AS ic ON icbc.inspection_case_id = ic.id
+        WHERE
+            icbc.box_code=#{code}
+            LIMIT 1
+    </select>
+
+
 </mapper>