lazhaoqian 4 rokov pred
rodič
commit
87e68ca619

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/anpin/StockControl.java

@@ -352,5 +352,15 @@ public class StockControl extends BaseController {
         ExcelUtil<InventoryLedgerExcel> util = new ExcelUtil<InventoryLedgerExcel>(InventoryLedgerExcel.class);
         return util.exportExcel(list, "库存总账统计表");
     }
+    @Log(title = "打印日志记录", businessType = BusinessType.DELETE)
+    @PostMapping("/updetePrintLog")
+    public AjaxResult updetePrintLog(@RequestBody TWarehouseBills tWarehouseBills) {
+        if (tWarehouseBills.getfId() == null) {
+            return AjaxResult.error("参数不能为空");
+        }
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tWarehousebillsService.updetePrintLog(tWarehouseBills,loginUser);
+
+    }
 
 }

+ 12 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/WarhousrExcel.java

@@ -21,6 +21,10 @@ public class WarhousrExcel {
     @Excel(name = "进货时间",dateFormat = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date fBsdate;
+    @Excel(name = "项目名称")
+    private String projectName;
+    @Excel(name = "出入库类别")
+    private String fBilltypeName;
     @Excel(name = "产品名称")
     private String feeName;
     @Excel(name = "规格")
@@ -54,8 +58,14 @@ public class WarhousrExcel {
     private String checkName;
     //物资类别中文名
     private String fFeetype;
-    //出入库类型
-    private String fBilltypeName;
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
 
     public String getNumber() {
         return number;

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

@@ -517,6 +517,21 @@ public class TWarehouseBills extends BaseEntity {
      */
     @Excel(name = "金额合计")
     private BigDecimal fMoney;
+    /** 生成日志 */
+    @Excel(name = "生成日志")
+    private String fCreateLog;
+
+    /** 打印日志 */
+    @Excel(name = "打印日志")
+    private String fPrintLog;
+
+    /** 打印次数 */
+    @Excel(name = "打印次数")
+    private Long fPrint;
+    /** 箱使日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "箱使日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date freeContainerDate;
 
     //起运港中文名
     private String loadportidName;
@@ -607,6 +622,38 @@ public class TWarehouseBills extends BaseEntity {
     //开始结束月
     private List<Long> monthList;
 
+    public Date getFreeContainerDate() {
+        return freeContainerDate;
+    }
+
+    public void setFreeContainerDate(Date freeContainerDate) {
+        this.freeContainerDate = freeContainerDate;
+    }
+
+    public String getfCreateLog() {
+        return fCreateLog;
+    }
+
+    public void setfCreateLog(String fCreateLog) {
+        this.fCreateLog = fCreateLog;
+    }
+
+    public String getfPrintLog() {
+        return fPrintLog;
+    }
+
+    public void setfPrintLog(String fPrintLog) {
+        this.fPrintLog = fPrintLog;
+    }
+
+    public Long getfPrint() {
+        return fPrint;
+    }
+
+    public void setfPrint(Long fPrint) {
+        this.fPrint = fPrint;
+    }
+
     public List<Long> getfFeeTypeList() {
         return fFeeTypeList;
     }
@@ -1791,6 +1838,10 @@ public class TWarehouseBills extends BaseEntity {
                 ", fMarketNumber=" + fMarketNumber +
                 ", fMoney=" + fMoney +
                 ", fPurchase=" + fPurchase +
+                ", fCreateLog=" + fCreateLog +
+                ", fPrintLog=" + fPrintLog +
+                ", fPrint=" + fPrint +
+                ", freeContainerDate=" + freeContainerDate +
                 '}';
     }
 }

+ 10 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehousebillsfees.java

@@ -344,6 +344,16 @@ public class TWarehousebillsfees extends BaseEntity {
     private Long fFeeType;
     //查询时间区间
     private List<String> cLoadDate;
+    //项目id
+    private Long fGoodsid;
+
+    public Long getfGoodsid() {
+        return fGoodsid;
+    }
+
+    public void setfGoodsid(Long fGoodsid) {
+        this.fGoodsid = fGoodsid;
+    }
 
     public List<String> getcLoadDate() {
         return cLoadDate;

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

@@ -469,6 +469,10 @@ public interface ITWarehouseBillsService {
      * @return
      */
     public AjaxResult generateReceipts(TWarehouseBills tWarehousebills,LoginUser loginUser);
+    /**
+     * 生成打印日志
+     */
+    public AjaxResult updetePrintLog(TWarehouseBills tWarehousebills,LoginUser loginUser);
 
     /**
      * 判断能否修改

+ 42 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -28,6 +28,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
 import com.ruoyi.reportManagement.domain.TWhgenleg;
+import com.ruoyi.reportManagement.dto.TWarehousebill;
 import com.ruoyi.reportManagement.mapper.TWhgenlegMapper;
 import com.ruoyi.shipping.domain.TCntr;
 import com.ruoyi.shipping.domain.TVoyage;
@@ -2026,14 +2027,34 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             }
         }
         if (i!= null && i>0){
+            //保存日志
+            String message = null;
+            if ("RK".equals(tWarehousebills.getfBilltype())){
+                message = "生成入库";
+            }else if ("CK".equals(tWarehousebills.getfBilltype())){
+                message = "生成出库";
+            }else if ("XS".equals(tWarehousebills.getfBilltype())){
+                message = "生成销售";
+            }
+            TWarehouseBills tWarehousebill = new TWarehouseBills();
+            tWarehousebill.setfId(tWarehousebills.getfId());
+            if (StringUtils.isNull(warehouseBills.getfCreateLog())){
+                tWarehousebill.setfCreateLog(message);
+            }else if (StringUtils.isNotEmpty(warehouseBills.getfCreateLog()) && warehouseBills.getfCreateLog().length() < 140) {
+                tWarehousebill.setfCreateLog(warehouseBills.getfCreateLog()+","+message);
+            }
+            Integer updateTWarehousebills = tWarehouseBillsMapper.updateTWarehousebills(tWarehousebill);
+            if (updateTWarehousebills == null || updateTWarehousebills <1){
+                return AjaxResult.error("生成日志出错,请联系管理员");
+            }
             return AjaxResult.success("success",warehouseBills.getfId());
         }else {
             String message = null;
-            if ("CKRK".equals(tWarehousebills.getfBilltype())){
+            if ("RK".equals(tWarehousebills.getfBilltype())){
                 message = "生成入库单失败,请找管理员";
-            }else if ("CKCK".equals(tWarehousebills.getfBilltype())){
+            }else if ("CK".equals(tWarehousebills.getfBilltype())){
                 message = "生成出库单失败,请找管理员";
-            }else if ("XSCK".equals(tWarehousebills.getfBilltype())){
+            }else if ("XS".equals(tWarehousebills.getfBilltype())){
                 message = "生成销售单失败,请找管理员";
             }
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -2042,6 +2063,23 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     }
 
     @Override
+    public AjaxResult updetePrintLog(TWarehouseBills tWarehousebills, LoginUser loginUser) {
+        TWarehouseBills tWarehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(tWarehousebills.getfId());
+        TWarehouseBills warehouseBills = new TWarehouseBills();
+        warehouseBills.setfId(tWarehouseBills.getfId());
+        warehouseBills.setfPrint(tWarehouseBills.getfPrint()+1);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String fPrintDate=sdf.format(new Date());
+        if (StringUtils.isNull(tWarehouseBills.getfPrintLog())){
+            warehouseBills.setfPrintLog(loginUser.getUser().getUserName()+","+ fPrintDate);
+        }else if (StringUtils.isNotEmpty(tWarehouseBills.getfPrintLog())&& tWarehouseBills.getfPrintLog().length() <110 ){
+            warehouseBills.setfPrintLog(tWarehouseBills.getfPrintLog()+","+ loginUser.getUser().getUserName()+","+ fPrintDate);
+        }
+        tWarehouseBillsMapper.updateTWarehousebills(warehouseBills);
+        return AjaxResult.success();
+    }
+
+    @Override
     public AjaxResult judge(TWarehouseBills tWarehouseBills) {
         TWarehouseBills warehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(tWarehouseBills.getfId());
         if (tWarehouseBills.getfDateChanged().equals(warehouseBills.getfDateChanged())){
@@ -3973,7 +4011,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         i =tWarehouseBillsMapper.updateTWarehousebills(tWarehousebills);
         i =tWarehousebillsfeesMapper.warehouseFeesFollowUpdate(tWarehousebills.getfId(), 2L, new Date());
         //撤销库存总账
-        if (billsType.equals("RK") || billsType.equals("CK")){
+        if (billsType.equals("RKRevoke") || billsType.equals("CKRevoke")){
             TWarehousebillsfees tWarehousebillsfees = new TWarehousebillsfees();
             tWarehousebillsfees.setfPid(fId);
             List<TWarehousebillsfees> tWarehousebillsfeesList = tWarehousebillsfeesMapper.selectTWarehousebillsfeesList(tWarehousebillsfees);

+ 26 - 3
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -96,6 +96,9 @@
         <result property="fTeachersWeight" column="f_teachers_weight"/>
         <result property="fMarketTypid" column="f_market_typid"/>
         <result property="fPurchase" column="f_purchase"/>
+        <result property="fCreateLog"    column="f_create_log"    />
+        <result property="fPrintLog"    column="f_print_log"    />
+        <result property="fPrint"    column="f_print"    />
     </resultMap>
     <sql id="selectTWarehousebillsVo">
         select f_id,
@@ -188,7 +191,10 @@
                f_money,
                f_teachers_weight,
                f_students_weight,
-               f_purchase
+               f_purchase,
+               f_create_log,
+               f_print_log,
+               f_print
         from t_warehousebills
     </sql>
 
@@ -681,7 +687,10 @@
                tw.f_teachers_weight,
                tw.f_students_weight,
                tw.f_purchase,
-               sr.user_name AS fpurchaseName
+               sr.user_name AS fpurchaseName,
+               tw.f_create_log,
+               tw.f_print_log,
+               tw.f_print
         FROM t_warehousebills tw
                  LEFT JOIN t_project tp ON tw.f_goodsid = tp.f_id
                  LEFT JOIN t_corps tc ON tp.f_corpid = tc.f_id
@@ -1017,6 +1026,10 @@
             <if test="fMarketNumber != null">f_market_number,</if>
             <if test="fMoney != null">f_money,</if>
             <if test="fPurchase != null">f_purchase,</if>
+            <if test="freeContainerDate != null">free_container_date,</if>
+            <if test="fCreateLog != null">f_create_log,</if>
+            <if test="fPrintLog != null">f_print_log,</if>
+            <if test="fPrint != null">f_print,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fBillno != null">#{fBillno},</if>
@@ -1109,6 +1122,10 @@
             <if test="fMarketNumber != null">#{fMarketNumber},</if>
             <if test="fMoney != null">#{fMoney},</if>
             <if test="fPurchase != null">#{fPurchase},</if>
+            <if test="freeContainerDate != null">#{freeContainerDate},</if>
+            <if test="fCreateLog != null">#{fCreateLog},</if>
+            <if test="fPrintLog != null">#{fPrintLog},</if>
+            <if test="fPrint != null">#{fPrint},</if>
         </trim>
     </insert>
 
@@ -1205,6 +1222,9 @@
             <if test="fMarketNumber != null">f_market_number = #{fMarketNumber},</if>
             <if test="fMoney != null">f_money = #{fMoney},</if>
             <if test="fPurchase != null">f_purchase = #{fPurchase},</if>
+            <if test="fCreateLog != null">f_create_log = #{fCreateLog},</if>
+            <if test="fPrintLog != null">f_print_log = #{fPrintLog},</if>
+            <if test="fPrint != null">f_print = #{fPrint},</if>
         </trim>
         where f_id = #{fId}
     </update>
@@ -2408,7 +2428,10 @@
         th.f_name AS fWarehouseName,
         tw.f_market_typid,
         tw.f_purchase,
-        tr.f_name    AS fsbuName
+        tr.f_name    AS fsbuName,
+        tw.f_create_log,
+        tw.f_print_log,
+        tw.f_print
         FROM
         t_warehousebills tw
         LEFT JOIN t_project tp

+ 22 - 17
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -1002,7 +1002,7 @@
         </where>
     </select>
     <!--安品出入库统计-->
-    <select id="selectTWarehouseInorOut" parameterType="TWarehousebills"
+    <select id="selectTWarehouseInorOut" parameterType="TWarehousebillsfees"
             resultType="com.ruoyi.anpin.WarhousrExcel">
         SELECT ti.f_bsdate AS fBsdate,/*进货时间*/
         tf.f_name AS feeName,/*物资名称*/
@@ -1018,6 +1018,7 @@
         sti.dict_label AS fIsfillesName,/*索证索票*/
         std.dict_label AS fFeetype,/*物资类别*/
         sr.user_name AS purchaseName,/*采购人*/
+        tp.f_name AS projectName,/*项目名称*/
         CASE
 
         WHEN tw.f_billtype = 'CK' THEN
@@ -1039,6 +1040,7 @@
         LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles
         AND sti.dict_type = 'f_evidence'
         LEFT JOIN t_warehousebills ti ON tw.f_pid = ti.f_id
+        LEFT JOIN t_project tp ON ti.f_goodsid = tp.f_id
         LEFT JOIN t_corps tc ON ti.f_corpid = tc.f_id
         LEFT JOIN sys_user sr ON sr.user_id = ti.f_purchase
         LEFT JOIN sys_dict_data std ON std.dict_value = tf.f_feetype
@@ -1049,6 +1051,7 @@
             <if test="fBillstatus != null  and fBillstatus == 1">and tw.f_billstatus = 6</if>
             <if test="fBillstatus != null  and fBillstatus == 2">and tw.f_billstatus != 6</if>
             <if test="fCorpid != null ">and ti.f_corpid = #{fCorpid}</if>
+            <if test="fGoodsid != null ">and ti.f_goodsid = #{fGoodsid}</if>
             <if test="fBilltype != null  and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
             <if test="fBilltype == null  or fBilltype == ''">and tw.f_billtype in ('CK','RK')</if>
             <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
@@ -1193,8 +1196,8 @@
         tf.f_billtype = 'XS'
         AND tf.del_flag = '0'
         AND tw.del_flag = '0'
-        AND tf.f_billstatus = 6
-        <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
+        <if test="fBillstatus != null  and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fGoodsid != null  and fGoodsid != ''">and tf.f_corpid = #{fGoodsid}</if>
         <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
         <if test="annual != null  and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
         <if test="monthList != null and monthList[0] != null and monthList[0]!= ''">
@@ -1213,7 +1216,7 @@
         ) xs
         LEFT JOIN (
         SELECT
-        tf.f_corpid,
+        tp.f_corpid,
         DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
         DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
         IFNULL( SUM( tf.f_amount ), 0 ) AS collect
@@ -1221,12 +1224,13 @@
         t_warehousebillsfees tf
         LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
         LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
+        LEFT JOIN t_project tp ON tp.f_id = tw.f_goodsid
         WHERE
         tf.f_billtype = 'SQ'
         AND tf.del_flag = '0'
         AND tw.del_flag = '0'
-        AND tf.f_billstatus = 6
-        <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
+        <if test="fBillstatus != null  and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fGoodsid != null  and fGoodsid != ''">and tp.f_corpid = #{fGoodsid}</if>
         <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
         <if test="annual != null  and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
         <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
@@ -1238,7 +1242,7 @@
         GROUP BY
         DATE_FORMAT( tf.f_bsdate, '%Y' ),
         DATE_FORMAT( tf.f_bsdate, '%m' ),
-        tf.f_corpid
+        tp.f_corpid
         ORDER BY
         DATE_FORMAT( tf.f_bsdate, '%Y' ),
         DATE_FORMAT( tf.f_bsdate, '%m' )
@@ -1268,7 +1272,7 @@
         FROM
         (
         SELECT
-        tf.f_corpid,
+        tp.f_corpid,
         DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
         DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
         IFNULL( SUM( tf.f_amount ), 0 ) AS collect
@@ -1276,12 +1280,13 @@
         t_warehousebillsfees tf
         LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
         LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
+        LEFT JOIN t_project tp ON tp.f_id = tw.f_goodsid
         WHERE
         tf.f_billtype = 'SQ'
         AND tf.del_flag = '0'
         AND tw.del_flag = '0'
-        AND tf.f_billstatus = 6
-        <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
+        <if test="fBillstatus != null  and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fGoodsid != null  and fGoodsid != ''">and tp.f_corpid = #{fGoodsid}</if>
         <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
         <if test="annual != null  and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
         <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
@@ -1293,7 +1298,7 @@
         GROUP BY
         DATE_FORMAT( tf.f_bsdate, '%Y' ),
         DATE_FORMAT( tf.f_bsdate, '%m' ),
-        tf.f_corpid
+        tp.f_corpid
         ORDER BY
         DATE_FORMAT( tf.f_bsdate, '%Y' ),
         DATE_FORMAT( tf.f_bsdate, '%m' )
@@ -1312,8 +1317,8 @@
         tf.f_billtype = 'XS'
         AND tf.del_flag = '0'
         AND tw.del_flag = '0'
-        AND tf.f_billstatus = 6
-        <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
+        <if test="fBillstatus != null  and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fGoodsid != null  and fGoodsid != ''">and tf.f_corpid = #{fGoodsid}</if>
         <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
         <if test="annual != null  and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
         <if test='monthList != null and monthList[0] != null and monthList[0]!= "" '>
@@ -1376,18 +1381,18 @@
         /*库区*/
         th.f_warehouse_information AS fWarehouseName,
         /*库区中文名*/
-        ifnull(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ),0) AS fBeginQty,
+        ifnull(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ),0) AS fBeginQty,
         /*期初数量*/
         ROUND(
         IFNULL((
-        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ))/(
-        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_qty ELSE 0 END )),
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ))/(
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END )),
         0
         ),
         2
         ) AS fBeginUnitprice,
         /*期初单价*/
-        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ),0) AS fBeginAmount,
+        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ),0) AS fBeginAmount,
         /*期初金额*/
         IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS rQty,
         /*入库数量*/