Selaa lähdekoodia

APP接口调整

Sun 3 vuotta sitten
vanhempi
commit
4ebb70f1d2
16 muutettua tiedostoa jossa 227 lisäystä ja 52 poistoa
  1. 28 2
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java
  2. 20 0
      ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
  3. 7 0
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java
  4. 7 0
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/ITWhgenlegService.java
  5. 14 0
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/impl/TWhgenlegServiceImpl.java
  6. 12 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseBills.java
  7. 0 13
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.java
  8. 24 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java
  9. 2 2
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java
  10. 7 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehousebillsitemsService.java
  11. 16 8
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java
  12. 20 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsitemsServiceImpl.java
  13. 22 8
      ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml
  14. 7 1
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml
  15. 0 18
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml
  16. 41 0
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

+ 28 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java

@@ -8,8 +8,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
+import com.ruoyi.reportManagement.service.ITWhgenlegService;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
+import com.ruoyi.warehouseBusiness.service.ITWarehousebillsitemsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,6 +33,12 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
     @Autowired
     private ITWarehouseBillsService itWarehouseBillsService;
 
+    @Autowired
+    private ITWarehousebillsitemsService itWarehousebillsitemsService;
+
+    @Autowired
+    private ITWhgenlegService itWhgenlegService;
+
     /**
      * 查询库存总账列表
      */
@@ -59,7 +67,7 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      */
     @GetMapping("/stockStatistics")
     public AjaxResult stockStatistics() {
-        return itWarehouseBillsService.stockStatistics();
+        return AjaxResult.success(itWarehouseBillsService.stockStatistics());
     }
 
     /**
@@ -67,7 +75,25 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      */
     @GetMapping("/cycleStockStatistics")
     public AjaxResult cycleStockStatistics() {
-        return itWarehouseBillsService.cycleStockStatistics();
+        return AjaxResult.success(itWarehouseBillsService.cycleStockStatistics());
+    }
+
+    /**
+     * 本月出入库列表
+     */
+    @GetMapping("/inAndOutStockMonthList")
+    public TableDataInfo inAndOutStockMonthList() {
+        startPage();
+        return getDataTable(itWarehousebillsitemsService.inAndOutStockMonthList());
+    }
+
+    /**
+     * 库龄超过60天的库存列表
+     */
+    @GetMapping("/stockAfterSixtyDaysList")
+    public TableDataInfo stockAfterSixtyDaysList() {
+        startPage();
+        return getDataTable(itWhgenlegService.stockAfterSixtyDaysList());
     }
 
 }

+ 20 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -410,6 +410,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return dateTime(cale.getTime());
     }
 
+    public static String beginOfLastWeek() {
+        Calendar cale = Calendar.getInstance();
+        cale.add(Calendar.WEEK_OF_MONTH, -1);
+        cale.set(Calendar.DAY_OF_WEEK, 2);
+        return dateTime(cale.getTime());
+    }
+
+    public static String endOfLastWeek() {
+        Calendar cale = Calendar.getInstance();
+        cale.set(Calendar.DAY_OF_WEEK, cale.getActualMinimum(Calendar.DAY_OF_WEEK));
+        return dateTime(cale.getTime());
+    }
+
     public static String beginOfMonth() {
         Calendar cale = Calendar.getInstance();
         cale.add(Calendar.MONTH, 0);
@@ -445,4 +458,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return dateTime(calendar.getTime());
     }
 
+    public static void main(String[] args) {
+        System.out.println(beginOfWeek());
+        System.out.println(endOfWeek());
+        System.out.println(beginOfLastWeek());
+        System.out.println(endOfLastWeek());
+    }
+
 }

+ 7 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java

@@ -173,4 +173,11 @@ public interface TWhgenlegMapper {
      * @return
      */
     public Map<String, Object> stockDays(@Param("external") String external);
+
+    /**
+     * 库龄超过60天的库存列表
+     *
+     * @return
+     */
+    public List<Map<String, Object>> stockAfterSixtyDaysList(@Param("external") String external);
 }

+ 7 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/ITWhgenlegService.java

@@ -157,4 +157,11 @@ public interface ITWhgenlegService {
      * @return
      */
     AjaxResult selectWhgenlegDetailsList(TWhgenleg tWhgenleg);
+
+    /**
+     * 库龄超过60天的库存列表
+     *
+     * @return
+     */
+    public List<Map<String, Object>> stockAfterSixtyDaysList();
 }

+ 14 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/impl/TWhgenlegServiceImpl.java

@@ -619,5 +619,19 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
         return result.setScale(2, BigDecimal.ROUND_HALF_UP);
     }
 
+    /**
+     * 库龄超过60天的库存列表
+     *
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> stockAfterSixtyDaysList() {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+        return tWhgenlegMapper.stockAfterSixtyDaysList(external);
+    }
 
 }

+ 12 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseBills.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.shipping.domain.TVoyage;
 import com.ruoyi.shipping.domain.TWarehousebillsCntr;
 import com.ruoyi.shipping.domain.TWarehousebillsCntritems;
@@ -1034,6 +1036,16 @@ public class TWarehouseBills extends BaseEntity {
      */
     private List<String> timeInterval;
 
+    private String external;
+
+    public String getExternal() {
+        return external;
+    }
+
+    public void setExternal(String external) {
+        this.external = external;
+    }
+
     public void settimeInterval(List<String> timeInterval) {
         this.timeInterval = timeInterval;
     }

+ 0 - 13
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.java

@@ -156,17 +156,4 @@ public interface TWarehousebillsfeesMapper extends BaseMapper<TWarehousebillsfee
      * @return
      */
     public List<Map<String,Object>> selectQueryMenuList(TWarehousebillsfees tWarehousebillsfees);
-
-    /**
-     * 出入库统计
-     * @param beginDate 起始时间
-     * @param endDate 截止时间
-     * @param billType 单据类型
-     * @param external 外部用户
-     * @return
-     */
-    public Map<String, Object> inAndOutStockStatistics(@Param("billType") String billType,
-                                                       @Param("beginDate") String beginDate,
-                                                       @Param("endDate") String endDate,
-                                                       @Param("external") String external);
 }

+ 24 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java

@@ -286,4 +286,28 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
      * @return
      */
     List<WarehouseTimeIntervalVO> selectInboundQtyByTime(@Param("dto") WarehouseDTO warehouseDto);
+
+    /**
+     * 出入库统计
+     * @param beginDate 起始时间
+     * @param endDate 截止时间
+     * @param billType 单据类型
+     * @param external 外部用户
+     * @return
+     */
+    public Map<String, Object> inAndOutStockStatistics(@Param("billType") String billType,
+                                                       @Param("beginDate") String beginDate,
+                                                       @Param("endDate") String endDate,
+                                                       @Param("external") String external);
+
+    /**
+     * 本月出入库列表
+     * @param beginDate 起始时间
+     * @param endDate 截止时间
+     * @param external 外部用户
+     * @return
+     */
+    public List<Map<String, Object>> inAndOutStockMonthList(@Param("beginDate") String beginDate,
+                                                       @Param("endDate") String endDate,
+                                                       @Param("external") String external);
 }

+ 2 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java

@@ -762,13 +762,13 @@ public interface ITWarehouseBillsService {
      *
      * @return
      */
-    AjaxResult stockStatistics();
+    public Map<String, String> stockStatistics();
 
     /**
      * 周期库存统计
      *
      * @return
      */
-    AjaxResult cycleStockStatistics();
+    public Map<String, String> cycleStockStatistics();
 
 }

+ 7 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehousebillsitemsService.java

@@ -84,4 +84,11 @@ public interface ITWarehousebillsitemsService {
      */
     AjaxResult warehouseComparison(WarehouseDTO warehouseDto);
 
+    /**
+     * 本月出入库列表
+     *
+     * @return
+     */
+    public List<Map<String, Object>> inAndOutStockMonthList();
+
 }

+ 16 - 8
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -2915,6 +2915,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
      */
     @Override
     public List<Map<String, Object>> selectAppStockList(TWarehouseBills warehouseBills) {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+        warehouseBills.setExternal(external);
         return tWarehouseBillsMapper.selectAppStockList(warehouseBills);
     }
 
@@ -7664,7 +7670,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
      * @return
      */
     @Override
-    public AjaxResult stockStatistics() {
+    public Map<String, String> stockStatistics() {
         String external = null;
         String customerName;
         SysUser user = SecurityUtils.getLoginUser().getUser();
@@ -7692,16 +7698,16 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         // 本周
         data.put("inStockTotalWeek", inAndOutStockStatistics("SJRK", DateUtils.beginOfWeek(), DateUtils.endOfWeek(), external));
         data.put("outStockTotalWeek", inAndOutStockStatistics("SJCK", DateUtils.beginOfWeek(), DateUtils.endOfWeek(), external));
+        // 上周
+        data.put("inStockTotalLastWeek", inAndOutStockStatistics("SJRK", DateUtils.beginOfLastWeek(), DateUtils.endOfLastWeek(), external));
+        data.put("outStockTotalLastWeek", inAndOutStockStatistics("SJCK", DateUtils.beginOfLastWeek(), DateUtils.endOfLastWeek(), external));
         // 本月
         data.put("inStockTotalMonth", inAndOutStockStatistics("SJRK", DateUtils.beginOfMonth(), DateUtils.endOfMonth(), external));
         data.put("outStockTotalMonth", inAndOutStockStatistics("SJCK", DateUtils.beginOfMonth(), DateUtils.endOfMonth(), external));
         // 上个月
         data.put("inStockTotalLastMonth", inAndOutStockStatistics("SJRK", DateUtils.beginOfLastMonth(), DateUtils.endOfLastMonth(), external));
         data.put("outStockTotalLastMonth", inAndOutStockStatistics("SJCK", DateUtils.beginOfLastMonth(), DateUtils.endOfLastMonth(), external));
-
-        // 库龄
-        data.put("stockDays", String.valueOf(tWhgenlegMapper.stockDays(external).get("days")));
-        return AjaxResult.success(data);
+        return data;
     }
 
     /**
@@ -7710,7 +7716,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
      * @return
      */
     @Override
-    public AjaxResult cycleStockStatistics() {
+    public Map<String, String> cycleStockStatistics() {
         String external = null;
         SysUser user = SecurityUtils.getLoginUser().getUser();
         if ("外部用户".equals(user.getDept().getDeptName())) {
@@ -7718,6 +7724,8 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         }
 
         Map<String, String> data = new HashMap<>();
+        // 库龄
+        data.put("stockDays", String.valueOf(tWhgenlegMapper.stockDays(external).get("days")));
         // 7天
         data.put("stockTotalA", stockStatistics(DateUtils.offsetDate(-6), null, external));
         // 15天
@@ -7732,13 +7740,13 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         data.put("stockTotalF", stockStatistics(DateUtils.offsetDate(-179), DateUtils.offsetDate(-89), external));
         // 180天+
         data.put("stockTotalG", stockStatistics(null, DateUtils.offsetDate(-179), external));
-        return AjaxResult.success(data);
+        return data;
     }
 
     private String inAndOutStockStatistics(String billType, String beginDate, String endDate, String external) {
         beginDate += " 00:00:00";
         endDate += " 23:59:59";
-        Map<String, Object> statistics = tWarehousebillsfeesMapper.inAndOutStockStatistics(billType, beginDate, endDate, external);
+        Map<String, Object> statistics = tWarehousebillsitemsMapper.inAndOutStockStatistics(billType, beginDate, endDate, external);
         return String.valueOf(statistics.get("total"));
     }
 

+ 20 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsitemsServiceImpl.java

@@ -4,9 +4,11 @@ package com.ruoyi.warehouseBusiness.service.impl;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.ruoyi.basicData.mapper.TWarehouseMapper;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.common.core.domain.enums.WarehouseEnum;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
 import com.ruoyi.warehouseBusiness.domain.dto.WarehouseDTO;
 import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
@@ -229,4 +231,22 @@ public class TWarehousebillsitemsServiceImpl implements ITWarehousebillsitemsSer
         return AjaxResult.success(secondItemsList);
     }
 
+    /**
+     * 本月出入库列表
+     *
+     * @return
+     */
+    @Override
+    public List<Map<String, Object>> inAndOutStockMonthList() {
+        String beginOfMonth = DateUtils.beginOfMonth();
+        String endOfMonth = DateUtils.endOfMonth();
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        return tWarehousebillsitemsMapper.inAndOutStockMonthList(beginOfMonth, endOfMonth, external);
+    }
+
 }

+ 22 - 8
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -834,6 +834,7 @@
             </if>
         </where>
         ${params.dataScope}
+        order by leg.f_bsdate desc
     </select>
     <select id="selectWhgenlegMessage" parameterType="TWhgenleg" resultType="com.ruoyi.reportManagement.excel.Whgenleg">
         select
@@ -1061,10 +1062,8 @@
     </select>
 
     <select id="stockStatistics" resultType="map">
-        select
-            round(ifnull(sum(f_grossweightblc) / 1000, 0)) as total
-        from
-            t_whgenleg
+        select round(ifnull(sum(f_grossweightblc) / 1000, 0)) as total
+        from t_whgenleg
         <where>
             <if test="beginDate != null and beginDate != ''">and f_bsdate &gt;= #{beginDate}</if>
             <if test="endDate != null and endDate != ''">and f_bsdate &lt; #{endDate}</if>
@@ -1075,10 +1074,8 @@
     </select>
 
     <select id="stockDays" resultType="map">
-        select
-            datediff(date_format(now(),'%Y-%m-%d'),date_format(min(f_bsdate),'%Y-%m-%d')) as days
-        from
-            t_whgenleg
+        select datediff(date_format(now(),'%Y-%m-%d'),date_format(min(f_bsdate),'%Y-%m-%d')) as days
+        from t_whgenleg
         where
             f_grossweightblc > 0
             <if test="external != null and external != ''">
@@ -1086,4 +1083,21 @@
             </if>
     </select>
 
+    <select id="stockAfterSixtyDaysList" resultType="map">
+        select
+            tw.f_mblno as fMblno,
+            tg.f_name as goodsName,
+            tw.f_bsdate as fBsdate,
+            round(tw.f_grossweightblc / 1000, 2) as fGrossweight
+        from t_whgenleg tw
+        left join t_goods tg ON tg.f_id = tw.f_goodsid
+        where
+            tw.f_grossweightblc > 0
+            and datediff(date_format(now(),'%Y-%m-%d'),date_format(tw.f_bsdate,'%Y-%m-%d')) > 60
+            <if test="external != null and external != ''">
+                and tw.f_corpid = (select f_corpid from t_customer_contact where f_tel = #{external})
+            </if>
+        order by tw.f_bsdate desc
+    </select>
+
 </mapper>

+ 7 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -2522,7 +2522,13 @@
         <if test='timeInterval != null and timeInterval[1] != null and timeInterval[1]!= ""'>
             and w.f_bsdate &lt;= #{timeInterval[1]}
         </if>
-            ${params.dataScope}
+        <if test="external != null and external != ''">
+            and w.f_warehouseid in (
+            select distinct f_warehouseid
+            from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
+            where f_tel = #{external})
+        </if>
+        <if test="external == null or external == ''">${params.dataScope}</if>
             order by w.f_id desc
     </select>
 

+ 0 - 18
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -904,22 +904,4 @@
         </where>
         ORDER BY tf.f_bsdate desc
     </select>
-
-    <select id="inAndOutStockStatistics" resultType="map">
-        select
-            round(ifnull(sum(ts.f_grossweight) / 1000, 0)) as total
-        from t_warehousebillsitems ts
-        left join t_warehousebills tb on ts.f_mblno = tb.f_mblno and ts.f_billno = tb.f_billno
-        where
-            ts.f_billstatus = '40'
-            <if test="billType != null and billType != ''">and tb.f_billtype = #{billType}</if>
-            <if test="beginDate != null and beginDate != ''">and ts.f_bsdate &gt;= #{beginDate}</if>
-            <if test="endDate != null and endDate != ''">and ts.f_bsdate &lt;= #{endDate}</if>
-            <if test="external != null and external != ''">
-                and tb.f_warehouseid in (
-                    select distinct f_warehouseid
-                    from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
-                    where f_tel = #{external})
-            </if>
-    </select>
 </mapper>

+ 41 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -952,4 +952,45 @@
         WHERE f_pid = #{pId}
     </update>
 
+    <select id="inAndOutStockStatistics" resultType="map">
+        select round(ifnull(sum(ts.f_grossweight) / 1000, 0)) as total
+        from t_warehousebillsitems ts
+        left join t_warehousebills tb on ts.f_mblno = tb.f_mblno and ts.f_billno = tb.f_billno
+        where
+            ts.f_billstatus = '40'
+            <if test="billType != null and billType != ''">and tb.f_billtype = #{billType}</if>
+            <if test="beginDate != null and beginDate != ''">and ts.f_bsdate &gt;= #{beginDate}</if>
+            <if test="endDate != null and endDate != ''">and ts.f_bsdate &lt;= #{endDate}</if>
+            <if test="external != null and external != ''">
+                and tb.f_warehouseid in (
+                select distinct f_warehouseid
+                from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
+                where f_tel = #{external})
+            </if>
+    </select>
+
+    <select id="inAndOutStockMonthList" resultType="map">
+        select
+            ts.f_mblno as fMblno,
+            tg.f_name as goodsName,
+            ts.f_bsdate as fBsdate,
+            round(ts.f_grossweight / 1000, 2) as fGrossweight,
+            case tb.f_billtype when 'SJRK' then '入库' when 'SJCK' then '出库' end as fBilltype,
+            ts.create_by as createBy
+        from t_warehousebillsitems ts
+        left join t_warehousebills tb on ts.f_mblno = tb.f_mblno and ts.f_billno = tb.f_billno
+        left join t_goods tg ON tg.f_id = ts.f_goodsid
+        where
+            ts.f_billstatus = '40'
+            and tb.f_billtype in ('SJRK', 'SJCK')
+            <if test="beginDate != null and beginDate != ''">and ts.f_bsdate &gt;= #{beginDate}</if>
+            <if test="endDate != null and endDate != ''">and ts.f_bsdate &lt;= #{endDate}</if>
+            <if test="external != null and external != ''">
+                and tb.f_warehouseid in (
+                select distinct f_warehouseid
+                from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
+                where f_tel = #{external})
+            </if>
+        order by ts.f_bsdate desc
+    </select>
 </mapper>