5 Commits 2691876731 ... 0dd4601aea

Tác giả SHA1 Thông báo Ngày
  zhangzhao 0dd4601aea 案件-流向 关联关系 3 năm trước cách đây
  zhangzhao 6ac84fb4d6 Merge remote-tracking branch 'origin/feature/1.0.0' into feature/1.0.0 3 năm trước cách đây
  zhangzhao afc73e6c97 稽查案件流向查询完善 3 năm trước cách đây
  zhangzhao f1710dd5e6 Merge remote-tracking branch 'origin/feature/1.0.0' into feature/1.0.0 3 năm trước cách đây
  zhangzhao 4d09bf5d5b swagger 内容修改 3 năm trước cách đây
16 tập tin đã thay đổi với 395 bổ sung58 xóa
  1. 2 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/FlowQueryRecordController.java
  2. 3 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/InspectionCaseController.java
  3. 1 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/InspectionCase.java
  4. 6 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/InspectionCaseFlow.java
  5. 15 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/InspectionCaseFlowMapper.java
  6. 5 2
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/InspectionCaseDetailVO.java
  7. 11 10
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/AddInspectionCaseReq.java
  8. 2 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/GetBoxCodeReq.java
  9. 3 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/PageListInspectionCaseReq.java
  10. 7 3
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetBoxCodeRes.java
  11. 45 1
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetInspectionCaseInfoRes.java
  12. 15 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/InspectionCaseFlowService.java
  13. 7 2
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/FlowQueryServiceImpl.java
  14. 35 0
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/InspectionCaseFlowServiceImpl.java
  15. 186 37
      abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/InspectionCaseServiceImpl.java
  16. 52 0
      abi-cloud-qr-platform-server/src/main/resources/dao/mapper/InspectionCaseFlowMapper.xml

+ 2 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/FlowQueryRecordController.java

@@ -10,6 +10,7 @@ import lombok.RequiredArgsConstructor;
 
 import javax.validation.constraints.*;
 
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -23,8 +24,8 @@ import io.swagger.annotations.ApiOperation;
  * @author ZhangZhao
  * @date 2021-07-21
  */
+@Slf4j
 @Api(value = "流向查询记录 控制器", tags = {"流向查询记录 管理"})
-@RequiredArgsConstructor(onConstructor_ = @Autowired)
 @RestController
 @RequestMapping("/flow/record")
 public class FlowQueryRecordController {

+ 3 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/console/InspectionCaseController.java

@@ -10,8 +10,10 @@ import com.abi.qms.platform.service.IInspectionCaseService;
 import com.abi.task.common.api.base.BaseResponse;
 import lombok.RequiredArgsConstructor;
 
+import javax.validation.Valid;
 import javax.validation.constraints.*;
 
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
@@ -25,8 +27,8 @@ import io.swagger.annotations.ApiOperation;
  * @author: ZhangZhao
  * @date: 2021-07-19
  */
+@Slf4j
 @Api(value = "稽查案件 控制器", tags = {"稽查案件 管理"})
-@RequiredArgsConstructor(onConstructor_ = @Autowired)
 @RestController
 @RequestMapping("/inspectionCase")
 public class InspectionCaseController {

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/InspectionCase.java

@@ -53,7 +53,7 @@ public class InspectionCase implements Serializable {
     /**
      * skuCode
      */
-    private Long skuCode;
+    private String skuCode;
 
     /**
      * 流货数量(箱)

+ 6 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/InspectionCaseFlow.java

@@ -28,12 +28,18 @@ public class InspectionCaseFlow implements Serializable {
     @Schema(name = "稽查案件id")
     private Long inspectionCaseId;
 
+    @Schema(name = "节点标识")
+    private Long nodeId;
+
     @Schema(name = "节点名称")
     private String nodeName;
 
     @Schema(name = "节点状态")
     private Integer nodeStatus;
 
+    @Schema(name = "异常类型 0-无异常 1-流入异常 2-流出异常")
+    private Integer abnormalType;
+
     @Schema(name = "是否拆垛")
     private Integer isSplit;
 

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

@@ -2,6 +2,9 @@ package com.abi.qms.platform.dao.mapper;
 
 import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 稽查案件-流向关联 Mapper接口
@@ -11,4 +14,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface InspectionCaseFlowMapper extends BaseMapper<InspectionCaseFlow> {
 
+    /**
+     * 批量保存
+     * @param flowList 流向信息列表
+     */
+    void insertBatch(@Param("list")  List<InspectionCaseFlow> flowList);
+
+    /**
+     * 根据案件ID删除相关箱码信息
+     *
+     * @param caseIds 案件ids
+     */
+    void deleteBatchCaseIds(@Param("caseIds") Long[] caseIds);
 }

+ 5 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/InspectionCaseDetailVO.java

@@ -1,13 +1,18 @@
 package com.abi.qms.platform.dao.vo.result;
 
+import com.abi.qms.platform.dto.res.GetInspectionCaseInfoRes;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.ToString;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * @author: ZhangZhao
@@ -84,7 +89,5 @@ public class InspectionCaseDetailVO implements Serializable {
     private String inAgencyName;
 
 
-    //TODO  流向信息
-
 
 }

+ 11 - 10
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/AddInspectionCaseReq.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.ToString;
 
+import javax.validation.Valid;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
@@ -30,55 +31,55 @@ public class AddInspectionCaseReq implements Serializable {
      * 案件编号生成策略 1-自动生成 2-自定义
      */
     @NotNull(message = "案件编号生成策略不能为空")
-    @ApiModelProperty(name = "案件编号生成策略 1-自动生成 2-自定义", required = true)
+    @ApiModelProperty(value = "案件编号生成策略 1-自动生成 2-自定义", required = true)
     private Integer caseNumberGenerateStrategy;
 
     /**
      * 省份id
      */
-    @ApiModelProperty(name = "省份ID")
+    @ApiModelProperty(value = "省份ID")
     private Long provinceId;
 
 
     /**
      * 城市id
      */
-    @ApiModelProperty(name = "城市ID")
+    @ApiModelProperty(value = "城市ID")
     private Long cityId;
 
     /**
      * 案件编号
      */
-    @ApiModelProperty(name = "自定义-案件编号(自定义编号时必传)")
+    @ApiModelProperty(value = "自定义-案件编号(自定义编号时必传)")
     private String caseNumber;
 
     /**
      * 案件名称
      */
     @NotBlank(message = "案件名称不能为空")
-    @ApiModelProperty(name = "案件名称", required = true)
+    @ApiModelProperty(value = "案件名称", required = true)
     private String caseName;
 
     /**
      * sku_id
      */
-    @NotNull(message = "sku_code不能为空")
-    @ApiModelProperty(name = "sku_code", required = true)
-    private Long skuCode;
+    @NotBlank(message = "sku_code不能为空")
+    @ApiModelProperty(value = "sku_code", required = true)
+    private String skuCode;
 
 
     /**
      * 案件备注
      */
     @Size(max = 150)
-    @ApiModelProperty(name = "案件备注")
+    @ApiModelProperty(value = "案件备注")
     private String caseRemark;
 
     /**
      * 案件涉及箱码列表
      */
     @Size(min = 1, message = "案件涉及箱码不能为空")
-    @ApiModelProperty(name = "案件涉及箱码列表", required = true)
+    @ApiModelProperty(value = "案件涉及箱码列表", required = true)
     private List<BoxCode> involvedBoxCodes;
 
 

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

@@ -1,6 +1,7 @@
 package com.abi.qms.platform.dto.req;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
@@ -14,6 +15,7 @@ import java.io.Serializable;
  */
 @Data
 @Schema
+@AllArgsConstructor
 public class GetBoxCodeReq implements Serializable {
 
     @Schema(name = "箱码")

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

@@ -9,6 +9,8 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
@@ -27,6 +29,7 @@ public class PageListInspectionCaseReq extends PageReq implements Serializable {
      * 案件编号/名称
      */
     @ApiModelProperty(value = "案件编号/名称")
+    @NotBlank(message = "不能为空!")
     private String caseNameOrNumber;
 
 

+ 7 - 3
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetBoxCodeRes.java

@@ -13,6 +13,7 @@ import java.util.List;
 /**
  * 箱码查询出参
  * TODO 测试使用,待流向查询接口完成后,根据实际情况调整结构
+ *
  * @author WeiganCai
  * @date: 2021-08-02
  */
@@ -45,7 +46,7 @@ public class GetBoxCodeRes implements Serializable {
         private String brandName;
 
         @Schema(name = "SKUId")
-        private Long skuId;
+        private String skuId;
 
         @Schema(name = "SKU名称")
         private String skuName;
@@ -77,14 +78,17 @@ public class GetBoxCodeRes implements Serializable {
     @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 = "异常类型 1-流入异常 2-流出异常")
-        private Integer abnormalType;
+        @Schema(name = "异常类型 0-无异常 1-流入异常 2-流出异常")
+        private Integer abnormalType = 0;
 
         @Schema(name = "是否拆垛")
         private Integer isSplit;

+ 45 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetInspectionCaseInfoRes.java

@@ -2,10 +2,14 @@ package com.abi.qms.platform.dto.res;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * @author: ZhangZhao
@@ -61,7 +65,47 @@ public class GetInspectionCaseInfoRes implements Serializable {
     private String inAgency;
 
 
+    /**
+     * 流向信息
+     */
+    private List<FlowBean> flowList;
+
+
+    /**
+     * 流向信息
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class FlowBean implements Serializable {
+
+        @Schema(name = "id")
+        private Long id;
+
+        @Schema(name = "节点标识")
+        private Long nodeId;
+
+        @Schema(name = "节点名称")
+        private String nodeName;
+
+        @Schema(name = "节点状态")
+        private Integer nodeStatus;
+
+        @Schema(name = "异常类型 0-无异常 1-流入异常 2-流出异常")
+        private Integer abnormalType;
+
+        @Schema(name = "是否拆垛")
+        private Integer isSplit;
+
+        @Schema(name = "拆垛托盘码")
+        private String splitStackCode;
+
+        @Schema(name = "入库时间")
+        private LocalDateTime inStorageTime;
+
+        @Schema(name = "出库时间")
+        private LocalDateTime outStorageTime;
+    }
+
 
-    //TODO  流向信息
 
 }

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

@@ -1,5 +1,9 @@
 package com.abi.qms.platform.service;
 
+import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
+
+import java.util.List;
+
 /**
  * 稽查案件-流向关联 Service接口
  *
@@ -8,4 +12,15 @@ package com.abi.qms.platform.service;
  */
 public interface InspectionCaseFlowService {
 
+    /**
+     * 保存【稽查案件-流向】关联关系
+     * @param flowList 流向节点列表
+     */
+    void saveInspectionCaseFlowList(List<InspectionCaseFlow> flowList);
+
+    /**
+     * 根据案件ID删除关联流向信息
+     * @param caseId 案件ID
+     */
+    void deleteByCaseId(final Long caseId);
 }

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

@@ -31,7 +31,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         GetBoxCodeRes.SkuBean sku = new GetBoxCodeRes.SkuBean()
                 .setBrandCode(320258L)
                 .setBrandName("百威")
-                .setSkuId(30859L)
+                .setSkuId("000000000000025000")
                 .setSkuName("百威9.7度500ML1X18纸箱听装-温州版")
                 .setProductionBatch("20210512CB0631HN-30")
                 .setProductionTime(LocalDateTime.of(2021, 5, 21, 13, 0, 0));
@@ -42,6 +42,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
 
         List flowList = new LinkedList();
         GetBoxCodeRes.FlowBean flow = new GetBoxCodeRes.FlowBean()
+                .setNodeId(8902L)
                 .setNodeName("CNA9-百威英博大富豪(盐城)啤酒有限公司")
                 .setNodeStatus(1)
                 .setIsSplit(0)
@@ -49,6 +50,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         flowList.add(flow);
 
         flow = new GetBoxCodeRes.FlowBean()
+                .setNodeId(8903L)
                 .setNodeName("上海吴泾DC")
                 .setNodeStatus(1)
                 .setIsSplit(1)
@@ -58,6 +60,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         flowList.add(flow);
 
         flow = new GetBoxCodeRes.FlowBean()
+                .setNodeId(8904L)
                 .setNodeName("一级经销商")
                 .setNodeStatus(1)
                 .setIsSplit(0)
@@ -66,6 +69,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         flowList.add(flow);
 
         flow = new GetBoxCodeRes.FlowBean()
+                .setNodeId(8905L)
                 .setNodeName("二级经销商")
                 .setNodeStatus(0)
                 .setAbnormalType(2)
@@ -76,6 +80,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         flowList.add(flow);
 
         flow = new GetBoxCodeRes.FlowBean()
+                .setNodeId(8906L)
                 .setNodeName("杭州市延海百利超市(新华小区店)")
                 .setNodeStatus(0)
                 .setAbnormalType(1)
@@ -85,7 +90,7 @@ public class FlowQueryServiceImpl implements FlowQueryService {
         Collections.reverse(flowList);
 
         GetBoxCodeRes.BoxStackBean boxStack = new GetBoxCodeRes.BoxStackBean()
-                .setBoxCode("abikcsy6fp47p10")
+                .setBoxCode(getBoxCodeReq.getBoxCode())
                 .setInvisibleCode("adb25416313")
                 .setOriginalStackCode("200700048457ADB2")
                 .setOriginalStackTime(LocalDateTime.of(2020, 12, 26, 11, 12, 38))

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

@@ -1,9 +1,18 @@
 package com.abi.qms.platform.service.impl;
 
+import com.abi.qms.platform.dao.entity.InspectionCaseBoxCode;
+import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
+import com.abi.qms.platform.dao.mapper.InspectionCaseFlowMapper;
+import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.service.InspectionCaseFlowService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 稽查案件-流向关联 Service业务层处理
  *
@@ -14,4 +23,30 @@ import org.springframework.stereotype.Service;
 @Slf4j
 public class InspectionCaseFlowServiceImpl implements InspectionCaseFlowService {
 
+
+    @Autowired
+    private InspectionCaseFlowMapper inspectionCaseFlowMapper;
+
+    /**
+     * 保存【稽查案件-流向】关联关系
+     * @param flowList 流向节点列表
+     */
+    @Override
+    public void saveInspectionCaseFlowList( List<InspectionCaseFlow> flowList) {
+        AssertUtil.isEmpty(flowList,"保存【稽查案件-流向】关联关系失败,流向信息为空!");
+        inspectionCaseFlowMapper.insertBatch(flowList);
+    }
+
+
+    /**
+     * 根据案件ID删除
+     * @param caseId 案件ID
+     */
+    @Override
+    public void deleteByCaseId(final Long caseId) {
+        AssertUtil.isNull(caseId,"根据案件ID删除【稽查案件-流向】关联关系失败,案件ID为空!");
+        QueryWrapper<InspectionCaseFlow> caseFlowQueryWrapper = new QueryWrapper<>();
+        caseFlowQueryWrapper.eq("inspection_case_id", caseId);
+        inspectionCaseFlowMapper.delete(caseFlowQueryWrapper);
+    }
 }

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

@@ -3,36 +3,42 @@ package com.abi.qms.platform.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.StrUtil;
 import com.abi.qms.platform.dao.entity.InspectionCase;
 import com.abi.qms.platform.dao.entity.InspectionCaseBoxCode;
+import com.abi.qms.platform.dao.entity.InspectionCaseFlow;
 import com.abi.qms.platform.dao.enums.CaseNumberGenerateStrategyEnum;
 import com.abi.qms.platform.dao.enums.ReqChannelTypeEnum;
 import com.abi.qms.platform.dao.mapper.InspectionCaseBoxCodeMapper;
+import com.abi.qms.platform.dao.mapper.InspectionCaseFlowMapper;
 import com.abi.qms.platform.dao.mapper.InspectionCaseMapper;
 import com.abi.qms.platform.dao.vo.result.InspectionCaseDetailVO;
 import com.abi.qms.platform.dao.vo.result.ListInspectionCaseVO;
 import com.abi.qms.platform.dao.vo.result.ListRoleVO;
 import com.abi.qms.platform.dto.req.AddInspectionCaseReq;
 import com.abi.qms.platform.dto.req.EditInspectionCaseReq;
+import com.abi.qms.platform.dto.req.GetBoxCodeReq;
 import com.abi.qms.platform.dto.req.PageListInspectionCaseReq;
-import com.abi.qms.platform.dto.res.GetInspectionCaseInfoRes;
-import com.abi.qms.platform.dto.res.ListRoleRes;
-import com.abi.qms.platform.dto.res.PageListInspectionCaseRes;
+import com.abi.qms.platform.dto.res.*;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.PageUtil;
+import com.abi.qms.platform.service.FlowQueryService;
 import com.abi.qms.platform.service.IInspectionCaseService;
+import com.abi.qms.platform.service.InspectionCaseFlowService;
+import com.abi.qms.platform.service.InspectionCaseNumberService;
 import com.abi.task.common.api.exception.BusinessException;
 import com.abi.task.common.utils.PojoConverterUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import jodd.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.validation.constraints.NotNull;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.time.LocalDateTime;
+import java.util.*;
 import java.util.function.Consumer;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
@@ -54,6 +60,17 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
     @Autowired
     private InspectionCaseBoxCodeMapper inspectionCaseBoxCodeMapper;
 
+    @Autowired
+    private InspectionCaseFlowMapper inspectionCaseFlowMapper;
+
+    @Autowired
+    private InspectionCaseNumberService caseNumberService;
+
+    @Autowired
+    private FlowQueryService flowQueryService;
+
+
+
     /**
      * 新增案件
      *
@@ -66,7 +83,12 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         //============先校验箱码============
         List<AddInspectionCaseReq.BoxCode> involvedBoxCodes = addReq.getInvolvedBoxCodes();
         List<String> boxCodeStrList = involvedBoxCodes.stream().map(AddInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
-        this.validatedBoxCode(boxCodeStrList);
+        //查询箱码流向信息
+        List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
+        //校验箱码信息
+        this.validatedBoxCode(flowInfoByBoxCodeList, addReq.getSkuCode());
+        //流向信息
+        List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
 
         //============案件编号============
         String caseNumber = addReq.getCaseNumber();
@@ -83,23 +105,37 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         List<InspectionCase> inspectionCaseList = inspectionCaseMapper.selectList(inspectionCaseQueryWrapper);
         AssertUtil.isEmpty(inspectionCaseList, "当前编号已存在!");
 
+
         //============保存案件============
-        //TODO 查询流向信息
 
         InspectionCase inspectionCase = new InspectionCase();
-        //TODO 设置流入 流出经销商
-        inspectionCase.setOutAgencyCode("T0001");
-        inspectionCase.setOutAgencyName("T_京城XXX超市");
-        inspectionCase.setInAgencyCode("T0002");
-        inspectionCase.setInAgencyName("T_京城XXX便利店");
-
         BeanUtil.copyProperties(addReq, inspectionCase);
+        //流出经销商 从 flowInfo 中取出
+        GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
+                .filter(s -> s.getAbnormalType().equals(2))
+                .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
+                .orElseThrow(() -> new BusinessException("没有流出异常节点"));
+
+        inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
+        inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
+
+        // 设置流入 经销商 从 flowInfo 中取出
+        GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
+                .filter(s -> s.getAbnormalType().equals(1))
+                .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
+                .orElseThrow(() -> new BusinessException("没有流入异常节点"));
+
+        inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
+        inspectionCase.setInAgencyName(inAgencyflowBean.getNodeName());
+        //流货数量
         inspectionCase.setBoxCodeCount((long) addReq.getInvolvedBoxCodes().size());
+        //案件名称
         inspectionCase.setCaseNumber(caseNumber);
         //设置渠道=>后台
         inspectionCase.setChannel(ReqChannelTypeEnum.BACKSTAGE.getCode());
         inspectionCaseMapper.insert(inspectionCase);
 
+
         //============保存涉案箱码============
         //转换类型
         List<InspectionCaseBoxCode> inspectionCaseBoxCodeList = involvedBoxCodes.stream()
@@ -109,10 +145,23 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
                     inspectionCaseBoxCode.setInspectionCaseId(inspectionCase.getId());
                     return inspectionCaseBoxCode;
                 }).collect(Collectors.toList());
-
         //批量保存
         inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
 
+
+        //============保存【案件-流向】关联============
+
+        List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
+            InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
+            BeanUtil.copyProperties(s,inspectionCaseFlow);
+            inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
+            return inspectionCaseFlow;
+        }).collect(Collectors.toList());
+
+        inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
+
+
+
     }
 
 
@@ -160,26 +209,41 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
     public void editInspectionCase(EditInspectionCaseReq editReq) {
 
         final Long caseId = editReq.getId();
+
+        InspectionCase inspectionCase = inspectionCaseMapper.selectById(caseId);
         //============校验箱码============
         //涉案箱码
         List<EditInspectionCaseReq.BoxCode> involvedBoxCodes = editReq.getInvolvedBoxCodes();
         List<String> boxCodeStrList = involvedBoxCodes.stream().map(EditInspectionCaseReq.BoxCode::getBoxCode).collect(Collectors.toList());
-        this.validatedBoxCode(boxCodeStrList);
-
+        //查询箱码流向信息
+        List<GetBoxCodeRes> flowInfoByBoxCodeList = this.getFlowInfoByBoxCodeList(boxCodeStrList);
+        //校验箱码信息
+        this.validatedBoxCode(flowInfoByBoxCodeList, inspectionCase.getSkuCode());
+        //流向信息
+        List<GetBoxCodeRes.FlowBean> flowList = flowInfoByBoxCodeList.get(0).getFlowList();
 
         //============修改案件信息============
-        //TODO 查询流向信息
+        //流出经销商 从 flowInfo 中取出
+        GetBoxCodeRes.FlowBean outAgencyFlowBean = flowList.stream()
+                .filter(s -> s.getAbnormalType().equals(2))
+                .min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime))
+                .orElseThrow(() -> new BusinessException("没有流出异常节点"));
 
-        InspectionCase inspectionCase = new InspectionCase();
-        //TODO 设置流入 流出经销商
-        inspectionCase.setOutAgencyCode("Test_0001");
-        inspectionCase.setOutAgencyName("Test_京城第一经销商");
-        inspectionCase.setInAgencyCode("Test_0002");
-        inspectionCase.setInAgencyName("Test_京城第二经销商");
+        inspectionCase.setOutAgencyCode(outAgencyFlowBean.getNodeId().toString());
+        inspectionCase.setOutAgencyName(outAgencyFlowBean.getNodeName());
+
+        // 设置流入 经销商 从 flowInfo 中取出
+        GetBoxCodeRes.FlowBean inAgencyflowBean = flowList.stream()
+                .filter(s -> s.getAbnormalType().equals(1))
+                .max(Comparator.comparing(GetBoxCodeRes.FlowBean::getInStorageTime))
+                .orElseThrow(() -> new BusinessException("没有流入异常节点"));
+
+        inspectionCase.setInAgencyCode(inAgencyflowBean.getNodeId().toString());
+        inspectionCase.setInAgencyName(inAgencyflowBean.getNodeName());
 
         inspectionCase.setBoxCodeCount((long) involvedBoxCodes.size());
-        inspectionCase.setId(caseId);
         inspectionCase.setCaseRemark(editReq.getCaseRemark());
+
         int i = inspectionCaseMapper.updateById(inspectionCase);
         //判断当前案件是否存在 i如果大于0表示 更新成功  否则表示未找到指定数据
         AssertUtil.isMeets(i, x -> x > 0, "当前案件已经不存在!");
@@ -196,11 +260,30 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
 
         //先删除当前案件下关联的箱码信息
         QueryWrapper<InspectionCaseBoxCode> boxCodeDeleteWrapper = new QueryWrapper<>();
-        boxCodeDeleteWrapper.eq("inspection_case_id", editReq.getId());
+        boxCodeDeleteWrapper.eq("inspection_case_id", caseId);
         inspectionCaseBoxCodeMapper.delete(boxCodeDeleteWrapper);
         //批量保存
         inspectionCaseBoxCodeMapper.insertBatch(inspectionCaseBoxCodeList);
 
+
+        //============修改【案件-流向】关联============
+
+        //先删除当前案件下关联流向信息
+        QueryWrapper<InspectionCaseFlow> inspectionCaseFlowQW = new QueryWrapper<>();
+        inspectionCaseFlowQW.eq("inspection_case_id", caseId);
+        inspectionCaseFlowMapper.delete(inspectionCaseFlowQW);
+
+        //保存新信息
+        List<InspectionCaseFlow> inspectionCaseFlowList = flowList.stream().map(s -> {
+            InspectionCaseFlow inspectionCaseFlow = new InspectionCaseFlow();
+            BeanUtil.copyProperties(s,inspectionCaseFlow);
+            inspectionCaseFlow.setInspectionCaseId(inspectionCase.getId());
+            return inspectionCaseFlow;
+        }).collect(Collectors.toList());
+
+        inspectionCaseFlowMapper.insertBatch(inspectionCaseFlowList);
+
+
     }
 
     /**
@@ -215,6 +298,9 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         inspectionCaseMapper.deleteBatchIds(Arrays.asList(ids));
         //删除关联的箱码信息
         inspectionCaseBoxCodeMapper.deleteBatchCaseIds(ids);
+        //删除【案件-流向】关联信息
+        inspectionCaseFlowMapper.deleteBatchCaseIds(ids);
+
     }
 
     /**
@@ -225,8 +311,9 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
      */
     @Override
     public GetInspectionCaseInfoRes getInspectionCaseInfo(final Long id) {
+        //案件信息
         InspectionCaseDetailVO caseDetailVO = inspectionCaseMapper.selectInspectionCaseDetailById(id);
-        AssertUtil.isNull(caseDetailVO, "此案件查询到!");
+        AssertUtil.isNull(caseDetailVO, "此案件查询到!");
 
         GetInspectionCaseInfoRes getInspectionCaseInfoRes = new GetInspectionCaseInfoRes();
         BeanUtil.copyProperties(caseDetailVO, getInspectionCaseInfoRes);
@@ -234,24 +321,88 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         getInspectionCaseInfoRes.setOutAgency(caseDetailVO.getOutAgencyCode() + caseDetailVO.getOutAgencyName());
         getInspectionCaseInfoRes.setInAgency(caseDetailVO.getInAgencyCode() + caseDetailVO.getInAgencyName());
 
+        //查询对应流向信息
+        QueryWrapper<InspectionCaseFlow> inspectionCaseFlowQW = new QueryWrapper<>();
+        inspectionCaseFlowQW.eq("inspection_case_id", id);
+        inspectionCaseFlowQW.orderByAsc("out_storage_time");
+        List<InspectionCaseFlow> inspectionCaseFlowList = inspectionCaseFlowMapper.selectList(inspectionCaseFlowQW);
+        //转换类型
+        List<GetInspectionCaseInfoRes.FlowBean> flowBeanList = PojoConverterUtils.copyList(inspectionCaseFlowList, GetInspectionCaseInfoRes.FlowBean.class);
+        getInspectionCaseInfoRes.setFlowList(flowBeanList);
+
         return getInspectionCaseInfoRes;
     }
 
 
+    /**
+     * 查询箱码对应流向信息
+     * @param boxCodeList 箱码列表
+     * @return 对应流向信息列表
+     */
+    private List<GetBoxCodeRes> getFlowInfoByBoxCodeList(List<String> boxCodeList) {
+        List<GetBoxCodeRes> getBoxCodeResList = new ArrayList<>();
+        boxCodeList.forEach(s -> {
+            GetBoxCodeReq boxCodeReq = new GetBoxCodeReq(s);
+            GetBoxCodeRes res = flowQueryService.boxCode(boxCodeReq);
+            AssertUtil.isNull(res, "案件新增失败!箱码:" + s + ",失败原因:未查询到此箱码信息!");
+            getBoxCodeResList.add(res);
+        });
+        return getBoxCodeResList;
+    }
+
+
     /**
      * 校验箱码
-     * 1、提交箱码的SKU信息是否一致,不一致则显示错误箱码;并列出错误原因
+     * 1、提交箱码的SKU信息是否一致,
      * 2、提交箱码的流向信息是否一致
+     * 不一致则显示错误箱码;并列出错误原因
      *
-     * @param boxCodeList 提交箱码列表
+     * @param boxCodeResList 箱码信息
+     * @return 流向信息
      */
-    private void validatedBoxCode(List<String> boxCodeList) {
-        //TODO  校验提交箱码所对应的SKU信息是否正确;、校验提交箱码的流向信息是否相同
-        //List<String> errorBoxCodeList=new ArrayList<>();
-        //校验失败 抛出异常 说明错误箱码;并列出错误原因
-        //AssertUtil.isEmpty(errorBoxCodeList,"案件新增失败!箱码:XXXX;XXXXX,失败原因:SKU信息不一致/流向信息不一致");
+    private void validatedBoxCode(List<GetBoxCodeRes> boxCodeResList, String skuCode) {
+
+        List<String> skuErrBoxCode = new ArrayList<>();
+        List<String> flowErrBoxCode = new ArrayList<>();
+
+        Set<LocalDateTime> outStorageTimeSet = new HashSet<LocalDateTime>();
+        List<Long> firstFlowNodeIdList = new ArrayList<>();
+
+        for (GetBoxCodeRes res : boxCodeResList) {
+
+            //箱码
+            String boxCode = res.getBoxStack().getBoxCode();
+
+            //判断SKU信息是否一致
+            String skuId = res.getSku().getSkuId();
+            if (!StrUtil.equals(skuId, skuCode)) {
+                skuErrBoxCode.add(boxCode);
+            }
+
+            //判断流向是否一致
+            //获取当前流向信息
+            List<GetBoxCodeRes.FlowBean> flowList = res.getFlowList();
+            LocalDateTime outStorageTime = flowList.stream().filter(s->Objects.nonNull(s.getOutStorageTime())).min(Comparator.comparing(GetBoxCodeRes.FlowBean::getOutStorageTime)).get().getOutStorageTime();
+            boolean outStorageTimeAdd = outStorageTimeSet.add(outStorageTime);
+
+            //获取当前所以流向节点ID
+            List<Long> nodeIds = flowList.stream().map(GetBoxCodeRes.FlowBean::getNodeId).collect(Collectors.toList());
+            //如果firstFlowNodeIdList 为空 则赋值
+            if (CollectionUtil.isEmpty(firstFlowNodeIdList)) {
+                firstFlowNodeIdList.addAll(nodeIds);
+                break;
+            }
+            //判断节点信息和时间信息是否一致
+            if (!CollectionUtil.containsAll(firstFlowNodeIdList, nodeIds) || !outStorageTimeAdd) {
+                flowErrBoxCode.add(boxCode);
+            }
+        }
+
+        AssertUtil.isEmpty(skuErrBoxCode, "案件新增失败!箱码:" + CollectionUtil.join(skuErrBoxCode, ";") + ",失败原因:SKU信息不一致");
+        AssertUtil.isEmpty(flowErrBoxCode, "案件新增失败!箱码:" + CollectionUtil.join(flowErrBoxCode, ";") + ",失败原因:流向信息不一致");
     }
 
+
     /**
      * 自动生成案件编号
      *
@@ -262,9 +413,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
     private String autoGenerateCaseNumber(Long provinceId, Long cityId) {
         AssertUtil.isNull(provinceId, "省份ID不能为空");
         AssertUtil.isNull(cityId, "城市ID不能为空");
-
-        //TODO 调用自动生成案件编号 接口 测试使用静态值替换
-        return "AUTO_" + System.currentTimeMillis();
+        return caseNumberService.getCaseNumber(cityId).toString();
     }
 
 

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

@@ -7,8 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="com.abi.qms.platform.dao.entity.InspectionCaseFlow" id="InspectionCaseFlowResult">
         <result property="id" column="id"/>
         <result property="inspectionCaseId" column="inspection_case_id"/>
+        <result property="nodeId" column="node_id"/>
         <result property="nodeName" column="node_name"/>
         <result property="nodeStatus" column="node_status"/>
+        <result property="abnormalType" column="abnormal_type"/>
         <result property="isSplit" column="is_split"/>
         <result property="splitStackCode" column="split_stack_code"/>
         <result property="inStorageTime" column="in_storage_time"/>
@@ -21,4 +23,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
 
+
+    <sql id="TableName">
+        `inspection_case_flow`
+    </sql>
+
+    <!--  批量保存  -->
+    <insert id="insertBatch" parameterType="java.util.List">
+        INSERT INTO
+        <include refid="TableName"/>
+        (
+        `inspection_case_id`,
+        `node_id`,
+        `node_name`,
+        `node_status`,
+        `abnormal_type`,
+        `is_split`,
+        `split_stack_code`,
+        `in_storage_time`,
+        `out_storage_time`
+        )
+        VALUES
+        <foreach item="item" index="index" collection="list" separator=",">
+            (
+            #{item.inspectionCaseId},
+            #{item.nodeId},
+            #{item.nodeName},
+            #{item.nodeStatus},
+            #{item.abnormalType},
+            #{item.isSplit},
+            #{item.splitStackCode},
+            #{item.inStorageTime},
+            #{item.outStorageTime}
+            )
+        </foreach>
+    </insert>
+
+
+    <update id="deleteBatchCaseIds" parameterType="java.lang.Long">
+        UPDATE
+        <include refid="TableName"/>
+        SET `is_delete`=1
+        WHERE
+        `inspection_case_id` IN
+        <foreach collection="caseIds" item="caseId" open="(" separator="," close=")">
+            #{caseId}
+        </foreach>
+    </update>
+
+
+
 </mapper>