Browse Source

取消sku关联查询

bess-WeiganCai 3 years ago
parent
commit
3b3524001f

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

@@ -45,6 +45,9 @@ public class InspectionCaseDetailVO implements Serializable {
     @ApiModelProperty(value = "案件名称")
     private String caseName;
 
+    @ApiModelProperty(value = "sku编码")
+    private String skuCode;
+
     /**
      * sku名称
      */

+ 3 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListFlowQueryRecordVO.java

@@ -60,6 +60,9 @@ public class ListFlowQueryRecordVO implements Serializable {
     @ApiModelProperty(value = "品牌名称", required = true)
     private String brandName;
 
+    @ApiModelProperty(value = "SKU编码")
+    private String skuCode;
+
     /**
      * SKU SKU-NAME
      */

+ 3 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListInspectionCaseVO.java

@@ -41,6 +41,9 @@ public class ListInspectionCaseVO implements Serializable {
     @ApiModelProperty(value = "案件名称")
     private String caseName;
 
+    @ApiModelProperty(value = "sku编码")
+    private String skuCode;
+
     /**
      * sku名称
      */

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

@@ -13,6 +13,7 @@ import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * @author: ZhangZhao
@@ -73,5 +74,8 @@ public class PageListInspectionCaseReq extends PageReq implements Serializable {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime endCreateTime;
 
+    /** 查询条件 */
+    private List<String> skuCodeList;
+
 
 }

+ 18 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/FlowQueryRecordServiceImpl.java

@@ -78,6 +78,15 @@ public class FlowQueryRecordServiceImpl implements IFlowQueryRecordService {
         //转换类型
         List<PageListFlowQueryRecordRes.FlowQueryRecordBean> flowQueryRecordBeanList = flowQueryRecordVOList.stream()
                 .parallel().map(s -> {
+                    // 查询sku
+                    String skuCode = s.getSkuCode();
+                    if (StringUtils.isNotBlank(skuCode)) {
+                        SkuFeign.Sku sku = skuFeign.getSkuByCode(skuCode);
+                        if (sku != null) {
+                            s.setSkuName(sku.getSkuName());
+                        }
+                    }
+
                     PageListFlowQueryRecordRes.FlowQueryRecordBean flowQueryRecordBean = new PageListFlowQueryRecordRes.FlowQueryRecordBean();
                     BeanUtil.copyProperties(s, flowQueryRecordBean);
 
@@ -157,6 +166,14 @@ public class FlowQueryRecordServiceImpl implements IFlowQueryRecordService {
     public GetFlowQueryRecordInfo getDetailsById(final Long id) {
         FlowQueryRecordInfoVo flowQueryRecordInfoVo = flowQueryRecordMapper.getDetailsById(id);
         AssertUtil.isNull(flowQueryRecordInfoVo, "未找到指定记录!");
+        //查询sku
+        String skuCode = flowQueryRecordInfoVo.getSkuCode();
+        if (StringUtils.isNotBlank(skuCode)) {
+            SkuFeign.Sku sku = skuFeign.getSkuByCode(skuCode);
+            if (sku != null) {
+                flowQueryRecordInfoVo.setSkuName(sku.getSkuName());
+            }
+        }
         //转换类型
         GetFlowQueryRecordInfo getFlowQueryRecordInfo = new GetFlowQueryRecordInfo();
         BeanUtil.copyProperties(flowQueryRecordInfoVo, getFlowQueryRecordInfo);
@@ -237,7 +254,7 @@ public class FlowQueryRecordServiceImpl implements IFlowQueryRecordService {
         recordList.forEach(record -> {
             String skuCode = record.getSkuCode();
             if (StringUtils.isNotBlank(skuCode)) {
-                SkuFeign.Sku sku = skuFeign.getSkuByCode(record.getSkuCode());
+                SkuFeign.Sku sku = skuFeign.getSkuByCode(skuCode);
                 if (sku != null) {
                     record.setSkuName(sku.getSkuName());
                 }

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

@@ -18,6 +18,7 @@ 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.*;
 import com.abi.qms.platform.dto.res.*;
+import com.abi.qms.platform.feign.SkuFeign;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.PageUtil;
 import com.abi.qms.platform.service.FlowQueryService;
@@ -31,9 +32,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.models.auth.In;
 import jodd.util.StringUtil;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
@@ -68,6 +71,9 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
     @Autowired
     private FlowQueryService flowQueryService;
 
+    @Autowired
+    private SkuFeign skuFeign;
+
     /**
      * 新增案件
      *
@@ -177,12 +183,34 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
      */
     @Override
     public PageListInspectionCaseRes pageListQuery(PageListInspectionCaseReq pageListReq) {
+        // sku编码或名称
+        String skuInfo = pageListReq.getSkuInfo();
+        if (StringUtils.isNotBlank(skuInfo)) {
+            List<SkuFeign.Sku> skuList = skuFeign.likeQuerySkuByCodeOrName(skuInfo);
+            List<String> skuCodeList = skuList.stream().map(sku -> sku.getSkuCode()).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(skuCodeList)) {
+                skuCodeList = new ArrayList<>();
+                // 查询不到
+                skuCodeList.add("-1");
+            }
+            pageListReq.setSkuCodeList(skuCodeList);
+        }
+
         IPage<ListInspectionCaseVO> pageResult = inspectionCaseMapper.pageListQuery(PageUtil.createPage(pageListReq), pageListReq);
         List<ListInspectionCaseVO> inspectionCaseVOList = pageResult.getRecords();
 
         //转换类型
         List<PageListInspectionCaseRes.InspectionCaseBean> inspectionCaseBeanList = inspectionCaseVOList.stream()
                 .parallel().map(s -> {
+                    // 查询sku
+                    String skuCode = s.getSkuCode();
+                    if (StringUtils.isNotBlank(skuCode)) {
+                        SkuFeign.Sku sku = skuFeign.getSkuByCode(skuCode);
+                        if (sku != null) {
+                            s.setSkuName(sku.getSkuName());
+                        }
+                    }
+
                     PageListInspectionCaseRes.InspectionCaseBean inspectionCaseBean = new PageListInspectionCaseRes.InspectionCaseBean();
                     BeanUtil.copyProperties(s, inspectionCaseBean);
                     //经销商
@@ -318,6 +346,15 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
         InspectionCaseDetailVO caseDetailVO = inspectionCaseMapper.selectInspectionCaseDetailById(id);
         AssertUtil.isNull(caseDetailVO, "此案件未查询到!");
 
+        //查询sku
+        String skuCode = caseDetailVO.getSkuCode();
+        if (StringUtils.isNotBlank(skuCode)) {
+            SkuFeign.Sku sku = skuFeign.getSkuByCode(skuCode);
+            if (sku != null) {
+                caseDetailVO.setSkuName(sku.getSkuName());
+            }
+        }
+
         GetInspectionCaseInfoRes getInspectionCaseInfoRes = new GetInspectionCaseInfoRes();
         BeanUtil.copyProperties(caseDetailVO, getInspectionCaseInfoRes);
 

+ 2 - 15
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/FlowQueryRecordMapper.xml

@@ -43,7 +43,7 @@
         <result property="trayCode" column="tray_code"/>
         <result property="brandCode" column="brand_code"/>
         <result property="brandName" column="brand_name"/>
-        <result property="skuName" column="sku_name"/>
+        <result property="skuCode" column="sku_code"/>
         <result property="queryType" column="query_type"/>
         <result property="queryPlatform" column="query_platform"/>
         <result property="queryAddress" column="query_address"/>
@@ -61,6 +61,7 @@
         <result property="flowStatus" column="flow_status"/>
         <result property="boxCode" column="box_code"/>
         <result property="trayCode" column="tray_code"/>
+        <result property="skuCode" column="sku_code"/>
         <result property="caseNumber" column="case_number"/>
         <result property="caseName" column="case_name"/>
         <result property="provinceName" column="province_name"/>
@@ -79,7 +80,6 @@
     </select>
 
     <sql id="queryList">
-        WITH fqr AS (
         SELECT
         `id`,
         `flow_status`,
@@ -141,12 +141,6 @@
                 AND `create_time` &lt;= #{param.endQueryTime}
             </if>
         </where>
-        ) SELECT
-        fqr.*,
-        sku.`sku_name`
-        FROM
-        fqr
-        LEFT JOIN `base_sap_sku` AS sku ON (fqr.`sku_code` = sku.`sku_code` AND sku.`is_delete`=0)
     </sql>
 
 
@@ -171,7 +165,6 @@
     <!--  查询记录详情 -->
     <select id="getDetailsById" resultMap="FlowQueryRecordInfoVo"
             parameterType="java.lang.Long">
-        WITH fqr AS (
         SELECT
         `id`,
         `flow_status`,
@@ -193,12 +186,6 @@
         id = #{id}
         AND
         <include refid="isNotDelete"/>
-        ) SELECT
-        fqr.*,
-        sku.`sku_name`
-        FROM
-        fqr
-        LEFT JOIN `base_sap_sku` AS sku ON (fqr.`sku_code` = sku.`sku_code` AND sku.`is_delete`=0)
     </select>
 
     <select id="wxPageListQuery" resultMap="WxListFlowQueryRecordVO">

+ 8 - 30
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/InspectionCaseMapper.xml

@@ -63,8 +63,6 @@
 
 
     <sql id="queryList">
-        WITH ic AS
-        (
         SELECT
         `id`,
         `case_number`,
@@ -82,6 +80,13 @@
         FROM `inspection_case`
         <where>
             <include refid="isNotDelete"/>
+            <!-- sku -->
+            <if test="param.skuInfo!=null and param.skuInfo!=''">
+                AND `sku_code` IN
+                <foreach collection="param.skuCodeList" item="skuCode" open="(" separator="," close=")">
+                    #{skuCode}
+                </foreach>
+            </if>
             <!--  案件编号/名称 支持输入案件编号和名称 支持模糊搜索-->
             <if test="param.caseNameOrNumber!=null and param.caseNameOrNumber!=''">
                 AND
@@ -122,24 +127,6 @@
                 AND `create_time` &lt;= #{param.endCreateTime}
             </if>
         </where>
-        )
-        SELECT
-        ic.*,
-        sku.`sku_name`
-        FROM
-        ic
-        LEFT JOIN `base_sap_sku` AS sku ON ( ic.`sku_code` = sku.`sku_code` AND sku.`is_delete`=0)
-        <where>
-            <!-- SKU信息 支持输入SKU的编码和名称 模糊查询 -->
-            <if test="param.skuInfo!=null and param.skuInfo!=''">
-                AND
-                (
-                LOCATE(#{param.skuInfo},ic.`sku_code`)>0
-                OR
-                LOCATE(#{param.skuInfo},sku.`sku_name`)>0
-                )
-            </if>
-        </where>
     </sql>
 
 
@@ -158,8 +145,7 @@
 
     <!-- 查询案件详情  -->
     <select id="selectInspectionCaseDetailById" parameterType="java.lang.Long" resultMap="InspectionCaseDetailVO">
-        WITH ic AS
-        (SELECT
+        SELECT
         `id`,
         `case_number` ,
         `case_name`,
@@ -178,14 +164,6 @@
                 AND `id`=#{caseId}
             </if>
         </where>
-        limit 1
-        )
-        select
-        ic.*,
-        sku.`sku_name`
-        FROM ic
-        LEFT JOIN ( SELECT `sku_code`, `sku_name` FROM `base_sap_sku` WHERE `is_delete` = 0 )
-        AS sku ON ic.`sku_code`=sku.`sku_code`
     </select>
 
 

+ 1 - 1
version.txt

@@ -1 +1 @@
-feature1.0.02106180956
+feature1.0.02108181627