Browse Source

物流数据优化

yzc 1 year ago
parent
commit
54a24ed7c5

+ 8 - 6
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/logistics/impl/LogisticsInfosServiceImpl.java

@@ -41,10 +41,7 @@ import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -82,12 +79,17 @@ public class LogisticsInfosServiceImpl extends ServiceImpl<LogisticsInfosMapper,
         wrapper.eq("li", LogisticsInfos::getLogisticsStatus, dto.getLogisticsStatus());
         wrapper.eq("li", LogisticsInfos::getStatus, dto.getStatus());
         if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
+            //判断是否是 采购到货 采购退货 来源
+            boolean flag = !Objects.equals(dto.getBusinessType(), 1) || !Objects.equals(dto.getBusinessType(), 5);
+
             List<String> companyCodes = companyInfoService.listObject(CompanyInfo::getCode, q -> q.like(CompanyInfo::getName, dto.getKeyword()));
             wrapper.and(q -> q.like("li", LogisticsInfos::getCode, dto.getKeyword())
                     .or().like("li", LogisticsInfos::getBusinessCode, dto.getKeyword())
                     .or().in("li", LogisticsInfos::getLogisticsCompanyCode, companyCodes)
-                    .or().like("pi.custom_code", dto.getKeyword())
-                    .or().like("pi.name", dto.getKeyword())
+                    .or(flag).like(flag,"pi.custom_code", dto.getKeyword())
+                    .or(flag).like(flag,"pi.name", dto.getKeyword())
+                    //采购到货 采购退货 来源
+                    .or().exists("select pd.purchase_id from bytesailing_purchase.purchase_detail pd LEFT JOIN bytesailing_item.product_info pi ON pd.bussiness_id = pi.id where ( pi.`name` LIKE CONCAT( '%', {0}, '%' ) OR pi.custom_code LIKE CONCAT( '%', {0}, '%' ))",dto.getKeyword())
             );
         }
 

+ 16 - 15
hx-victoriatourist/src/main/resources/mapper/logistics/LogisticsInfosMapper.xml

@@ -24,37 +24,38 @@
             li.address,
             li.purchase_id,
             li.arrival_remark,
-            de.dept_name
-            <if test="businessType eq 1 or businessType eq 5">
-               ,dg.status arrivalStatus
-            </if>
+            de.dept_name,
+            dg.status arrivalStatus
         from logistics_infos li
+            LEFT JOIN deliver_goods dg on li.business_id = dg.id
+            LEFT JOIN bytesailing_purchase.purchase p ON p.id = li.purchase_id
                 <!-- 采购到货 采购退货 来源 -->
                 <if test="businessType eq 1 or businessType eq 5">
-                    LEFT JOIN deliver_goods dg on li.business_id = dg.id
-                    LEFT JOIN bytesailing_purchase.purchase p ON li.purchase_id = p.id
-                    LEFT JOIN bytesailing_purchase.purchase_detail pd ON pd.purchase_id = p.id
-                    LEFT JOIN bytesailing_item.product_info pi ON pd.bussiness_id = pi.id
+--                     LEFT JOIN bytesailing_purchase.purchase_detail pd ON pd.purchase_id = li.purchase_id
+--                     LEFT JOIN bytesailing_item.product_info pi ON pd.bussiness_id = pi.id
                 </if>
                 <!-- 京东退货来源 -->
                 <if test="businessType eq 4">
-                    LEFT JOIN jd_back jb ON li.business_id = jb.id
-                    LEFT JOIN jd_back_details jbd ON jbd.jd_back_id = jb.id
+                    LEFT JOIN jd_back_details jbd ON jbd.jd_back_id = li.business_id
                     LEFT JOIN bytesailing_item.product_info pi ON jbd.product_code = pi.custom_code
                 </if>
                 <!-- 京东订单来源 -->
                 <if test="businessType eq 2">
-                    LEFT JOIN jd_order jo ON li.business_id = jo.id
-                    LEFT JOIN jd_order_details jod ON jod.jd_order_id = jo.id
+                    LEFT JOIN jd_order_details jod ON jod.jd_order_id = li.business_id
                     LEFT JOIN bytesailing_item.product_info pi ON jod.product_id = pi.id
                 </if>
                 <!-- 销售订单来源 -->
                 <if test="businessType eq 3">
-                    LEFT JOIN order_info oi ON li.business_id = oi.id
-                    LEFT JOIN order_details od ON od.order_id = oi.id
+                    LEFT JOIN order_details od ON od.order_id = li.business_id
                     LEFT JOIN bytesailing_item.product_info pi ON od.product_id = pi.id
                 </if>
-                LEFT JOIN bytesailing_base.sys_dept de ON CAST(json_unquote(pi.victoriatourist_json -> '$.deptId') AS UNSIGNED) = de.dept_id
+                LEFT JOIN bytesailing_base.sys_dept de ON
+                <if test="businessType neq 1 and businessType neq 5">
+                    pi.deptWdly = de.dept_id
+                </if>
+                <if test="businessType eq 1 or businessType eq 5">
+                     p.team_id=de.dept_id
+                </if>
             ${ew.customSqlSegment}
     </select>
     <select id="getDepts" resultType="com.ruoyi.common.core.domain.entity.SysDept">