lazhaoqian пре 4 година
родитељ
комит
33aa615c31
19 измењених фајлова са 676 додато и 38 уклоњено
  1. 35 3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/anpin/StockControl.java
  2. 5 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/anpin/TMonthEndingClosingController.java
  3. BIN
      ruoyi-admin/target/classes/com/ruoyi/web/controller/monitor/CacheController.class
  4. BIN
      ruoyi-admin/target/classes/com/ruoyi/web/controller/system/SysUserController.class
  5. 290 0
      ruoyi-warehouse/src/main/java/com/ruoyi/anpin/InventoryLedgerExcel.java
  6. 4 0
      ruoyi-warehouse/src/main/java/com/ruoyi/anpin/ProfitExcel.java
  7. 15 1
      ruoyi-warehouse/src/main/java/com/ruoyi/anpin/SalesOfOutbound.java
  8. 4 0
      ruoyi-warehouse/src/main/java/com/ruoyi/anpin/TMonthEndingClosingExcel.java
  9. 1 1
      ruoyi-warehouse/src/main/java/com/ruoyi/anpin/WarhousrExcel.java
  10. 8 4
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.java
  11. 7 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java
  12. 70 6
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java
  13. 7 2
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml
  14. 111 9
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml
  15. BIN
      ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.class
  16. BIN
      ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.class
  17. BIN
      ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.class
  18. 7 2
      ruoyi-warehouse/target/classes/mapper/warehouseBusiness/TWarehousebillsMapper.xml
  19. 112 9
      ruoyi-warehouse/target/classes/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

+ 35 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/anpin/StockControl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.web.controller.anpin;
 
 import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.ruoyi.anpin.InventoryLedgerExcel;
 import com.ruoyi.anpin.ProfitExcel;
 import com.ruoyi.anpin.SalesOfOutbound;
 import com.ruoyi.anpin.WarhousrExcel;
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -290,7 +293,7 @@ public class StockControl extends BaseController {
      * 导出销售出库统计列表
      */
     @PreAuthorize("@ss.hasPermi('anpin:stockControl:salesOfOutboundExcePorrt')")
-    @Log(title = "导出出库统计表", businessType = BusinessType.EXPORT)
+    @Log(title = "导出销售出库统计表", businessType = BusinessType.EXPORT)
     @GetMapping("/salesOfOutboundExcePorrt/export")
     public AjaxResult salesOfOutboundExcePorrt(TWarehouseBills tWarehouseBills)
     {
@@ -312,13 +315,42 @@ public class StockControl extends BaseController {
      * 导出利润统计列表
      */
     @PreAuthorize("@ss.hasPermi('anpin:stockControl:salectAnpinProfitExcePorrt')")
-    @Log(title = "导出出入库统计表", businessType = BusinessType.EXPORT)
+    @Log(title = "导出利润统计表", businessType = BusinessType.EXPORT)
     @GetMapping("/salectAnpinProfit/export")
     public AjaxResult salectAnpinProfitExcePorrt(TWarehouseBills tWarehouseBills)
     {
         List<ProfitExcel> list = tWarehousebillsService.salectAnpinProfit(tWarehouseBills);
         ExcelUtil<ProfitExcel> util = new ExcelUtil<ProfitExcel>(ProfitExcel.class);
-        return util.exportExcel(list, "销售出库统计表");
+        return util.exportExcel(list, "利润统计表");
+    }
+    /**
+     * 库存总账
+     */
+    @PreAuthorize("@ss.hasPermi('anpin:stockControl:selectInventoryLedger')")
+    @GetMapping("/selectInventoryLedger")
+    public TableDataInfo selectInventoryLedger(TWarehouseBills tWarehouseBills) {
+        startPage();
+        List<InventoryLedgerExcel> list = new ArrayList<>();
+        if (CollectionUtils.isEmpty(tWarehouseBills.gettimeInterval()) || "[]".equals(tWarehouseBills.gettimeInterval())){
+            return getDataTable(list);
+        }
+        list = tWarehousebillsService.selectInventoryLedger(tWarehouseBills);
+        return getDataTable(list);
+    }
+    /**
+     * 库存总账
+     */
+    @PreAuthorize("@ss.hasPermi('anpin:stockControl:selectInventoryLedgerExcePorrt')")
+    @Log(title = "导出库存总账统计表", businessType = BusinessType.EXPORT)
+    @GetMapping("/selectInventoryLedger/export")
+    public AjaxResult selectInventoryLedgerExcePorrt(TWarehouseBills tWarehouseBills)
+    {
+        List<InventoryLedgerExcel> list = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(tWarehouseBills.gettimeInterval()) || !"[]".equals(tWarehouseBills.gettimeInterval())) {
+            list = tWarehousebillsService.selectInventoryLedger(tWarehouseBills);
+        }
+        ExcelUtil<InventoryLedgerExcel> util = new ExcelUtil<InventoryLedgerExcel>(InventoryLedgerExcel.class);
+        return util.exportExcel(list, "库存总账统计表");
     }
 
 }

+ 5 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/anpin/TMonthEndingClosingController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.anpin;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import com.ruoyi.anpin.domain.TMonthEndingClosing;
@@ -43,7 +44,10 @@ public class TMonthEndingClosingController extends BaseController
     public TableDataInfo list(TMonthEndingClosing tMonthEndingClosing)
     {
         startPage();
-        List<TMonthEndingClosing> list = tMonthEndingClosingService.selectTMonthEndingClosingList(tMonthEndingClosing);
+        List<TMonthEndingClosing> list = new ArrayList<>();
+        if (tMonthEndingClosing.getfYear() != 0){
+            list = tMonthEndingClosingService.selectTMonthEndingClosingList(tMonthEndingClosing);
+        }
         return getDataTable(list);
     }
 

BIN
ruoyi-admin/target/classes/com/ruoyi/web/controller/monitor/CacheController.class


BIN
ruoyi-admin/target/classes/com/ruoyi/web/controller/system/SysUserController.class


+ 290 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/InventoryLedgerExcel.java

@@ -0,0 +1,290 @@
+package com.ruoyi.anpin;
+
+import com.ruoyi.common.annotation.Excel;
+
+import java.math.BigDecimal;
+
+/**
+ * @Author ZhaoQian La
+ * @Date 2021/6/8 8:54
+ * @Version 1.0
+ */
+public class InventoryLedgerExcel {
+    private static final long serialVersionUID = 1L;
+    //年
+    @Excel(name = "年")
+    private String fyears;
+    //月
+    @Excel(name = "月")
+    private String fmonth;
+    //客户id
+    private Long fCorpid;
+    //客户中文名
+    @Excel(name = "供应商")
+    private String fCorpName;
+    //货物id
+    private Long fFeeid;
+    //货物中文名
+    @Excel(name = "货物")
+    private String fFName;
+    //包装单位
+    @Excel(name = "包装单位")
+    private String fCurrency;
+    //货物类别
+    private Long feetype;
+    //货物类别名称
+    @Excel(name = "货物类别")
+    private String feetypeName;
+    //计价单位id
+    private Long fFeeUnitid;
+    @Excel(name = "计价单位")
+    private String feeUnitName;
+    //库区id
+    private Long fWarehouseid;
+    //库区中文名
+    @Excel(name = "库区")
+    private String fWarehouseName;
+    //期初数量
+    @Excel(name = "期初数量")
+    private BigDecimal fBeginQty;
+    //期初单价
+    @Excel(name = "期初单价")
+    private BigDecimal fBeginUnitprice;
+    //期初金额
+    @Excel(name = "期初金额")
+    private BigDecimal fBeginAmount;
+    //入库数量
+    @Excel(name = "入库数量")
+    private BigDecimal rQty;
+    //入库金额
+    @Excel(name = "入库金额")
+    private BigDecimal rfAmount;
+    //出库数量
+    @Excel(name = "出库数量")
+    private BigDecimal cQty;
+    //出库金额
+    @Excel(name = "出库金额")
+    private BigDecimal cfAmount;
+    //结余数量
+    @Excel(name = "结余数量")
+    private BigDecimal fAfterQty;
+    //结余单价
+    @Excel(name = "结余单价")
+    private BigDecimal fAfterUnitprice;
+    //结余金额
+    @Excel(name = "结余金额")
+    private BigDecimal fAfterAmount;
+
+    public String getFyears() {
+        return fyears;
+    }
+
+    public void setFyears(String fyears) {
+        this.fyears = fyears;
+    }
+
+    public String getFmonth() {
+        return fmonth;
+    }
+
+    public void setFmonth(String fmonth) {
+        this.fmonth = fmonth;
+    }
+
+    public Long getfCorpid() {
+        return fCorpid;
+    }
+
+    public void setfCorpid(Long fCorpid) {
+        this.fCorpid = fCorpid;
+    }
+
+    public String getfCorpName() {
+        return fCorpName;
+    }
+
+    public void setfCorpName(String fCorpName) {
+        this.fCorpName = fCorpName;
+    }
+
+    public Long getfFeeid() {
+        return fFeeid;
+    }
+
+    public void setfFeeid(Long fFeeid) {
+        this.fFeeid = fFeeid;
+    }
+
+    public String getfFName() {
+        return fFName;
+    }
+
+    public void setfFName(String fFName) {
+        this.fFName = fFName;
+    }
+
+    public String getfCurrency() {
+        return fCurrency;
+    }
+
+    public void setfCurrency(String fCurrency) {
+        this.fCurrency = fCurrency;
+    }
+
+    public Long getFeetype() {
+        return feetype;
+    }
+
+    public void setFeetype(Long feetype) {
+        this.feetype = feetype;
+    }
+
+    public String getFeetypeName() {
+        return feetypeName;
+    }
+
+    public void setFeetypeName(String feetypeName) {
+        this.feetypeName = feetypeName;
+    }
+
+    public Long getfFeeUnitid() {
+        return fFeeUnitid;
+    }
+
+    public void setfFeeUnitid(Long fFeeUnitid) {
+        this.fFeeUnitid = fFeeUnitid;
+    }
+
+    public String getFeeUnitName() {
+        return feeUnitName;
+    }
+
+    public void setFeeUnitName(String feeUnitName) {
+        this.feeUnitName = feeUnitName;
+    }
+
+    public Long getfWarehouseid() {
+        return fWarehouseid;
+    }
+
+    public void setfWarehouseid(Long fWarehouseid) {
+        this.fWarehouseid = fWarehouseid;
+    }
+
+    public String getfWarehouseName() {
+        return fWarehouseName;
+    }
+
+    public void setfWarehouseName(String fWarehouseName) {
+        this.fWarehouseName = fWarehouseName;
+    }
+
+    public BigDecimal getfBeginQty() {
+        return fBeginQty;
+    }
+
+    public void setfBeginQty(BigDecimal fBeginQty) {
+        this.fBeginQty = fBeginQty;
+    }
+
+    public BigDecimal getfBeginUnitprice() {
+        return fBeginUnitprice;
+    }
+
+    public void setfBeginUnitprice(BigDecimal fBeginUnitprice) {
+        this.fBeginUnitprice = fBeginUnitprice;
+    }
+
+    public BigDecimal getfBeginAmount() {
+        return fBeginAmount;
+    }
+
+    public void setfBeginAmount(BigDecimal fBeginAmount) {
+        this.fBeginAmount = fBeginAmount;
+    }
+
+    public BigDecimal getrQty() {
+        return rQty;
+    }
+
+    public void setrQty(BigDecimal rQty) {
+        this.rQty = rQty;
+    }
+
+    public BigDecimal getRfAmount() {
+        return rfAmount;
+    }
+
+    public void setRfAmount(BigDecimal rfAmount) {
+        this.rfAmount = rfAmount;
+    }
+
+    public BigDecimal getcQty() {
+        return cQty;
+    }
+
+    public void setcQty(BigDecimal cQty) {
+        this.cQty = cQty;
+    }
+
+    public BigDecimal getCfAmount() {
+        return cfAmount;
+    }
+
+    public void setCfAmount(BigDecimal cfAmount) {
+        this.cfAmount = cfAmount;
+    }
+
+    public BigDecimal getfAfterQty() {
+        return fAfterQty;
+    }
+
+    public void setfAfterQty(BigDecimal fAfterQty) {
+        this.fAfterQty = fAfterQty;
+    }
+
+    public BigDecimal getfAfterUnitprice() {
+        return fAfterUnitprice;
+    }
+
+    public void setfAfterUnitprice(BigDecimal fAfterUnitprice) {
+        this.fAfterUnitprice = fAfterUnitprice;
+    }
+
+    public BigDecimal getfAfterAmount() {
+        return fAfterAmount;
+    }
+
+    public void setfAfterAmount(BigDecimal fAfterAmount) {
+        this.fAfterAmount = fAfterAmount;
+    }
+
+    @Override
+    public String toString() {
+        return "InventoryLedgerExcel{" +
+                "fyears='" + fyears + '\'' +
+                ", fmonth='" + fmonth + '\'' +
+                ", fCorpid=" + fCorpid +
+                ", fCorpName='" + fCorpName + '\'' +
+                ", fFeeid=" + fFeeid +
+                ", fFName='" + fFName + '\'' +
+                ", fCurrency='" + fCurrency + '\'' +
+                ", feetype=" + feetype +
+                ", feetypeName='" + feetypeName + '\'' +
+                ", fFeeUnitid=" + fFeeUnitid +
+                ", feeUnitName='" + feeUnitName + '\'' +
+                ", fWarehouseid=" + fWarehouseid +
+                ", fWarehouseName='" + fWarehouseName + '\'' +
+                ", fBeginQty=" + fBeginQty +
+                ", fBeginUnitprice=" + fBeginUnitprice +
+                ", fBeginAmount=" + fBeginAmount +
+                ", rQty=" + rQty +
+                ", rfAmount=" + rfAmount +
+                ", cQty=" + cQty +
+                ", cfAmount=" + cfAmount +
+                ", fAfterQty=" + fAfterQty +
+                ", fAfterUnitprice=" + fAfterUnitprice +
+                ", fAfterAmount=" + fAfterAmount +
+                '}';
+    }
+}

+ 4 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/ProfitExcel.java

@@ -10,6 +10,10 @@ import java.util.List;
  * @Date 2021/6/4 11:50
  * @Version 1.0
  */
+
+/**
+ * 利润总账
+ */
 public class ProfitExcel {
     private static final long serialVersionUID = 1L;
 

+ 15 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/SalesOfOutbound.java

@@ -1,8 +1,10 @@
 package com.ruoyi.anpin;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * @Author ZhaoQian La
@@ -11,7 +13,7 @@ import java.math.BigDecimal;
  */
 
 /**
- * 导出销售出库
+ * 销售出库统计
  */
 public class SalesOfOutbound {
     private static final long serialVersionUID = 1L;
@@ -20,6 +22,9 @@ public class SalesOfOutbound {
     //项目名称
     @Excel(name = "客户项目")
     private String projectName;
+    @Excel(name = "出库日期",dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date fBsdate;
     //物资类别
     private Long ffeetype;
     //物资类别中文名
@@ -46,6 +51,14 @@ public class SalesOfOutbound {
     @Excel(name = "金额")
     private BigDecimal famount;
 
+    public Date getfBsdate() {
+        return fBsdate;
+    }
+
+    public void setfBsdate(Date fBsdate) {
+        this.fBsdate = fBsdate;
+    }
+
     public Long getFgoodsid() {
         return fgoodsid;
     }
@@ -148,6 +161,7 @@ public class SalesOfOutbound {
                 ", ffeeunitidName='" + ffeeunitidName + '\'' +
                 ", price=" + price +
                 ", famount=" + famount +
+                ", fBsdate=" + fBsdate +
                 '}';
     }
 }

+ 4 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/TMonthEndingClosingExcel.java

@@ -10,6 +10,10 @@ import java.util.Date;
  * @Date 2021/6/7 14:46
  * @Version 1.0
  */
+
+/**
+ * 月末结账
+ */
 public class TMonthEndingClosingExcel {
     private static final long serialVersionUID = 1L;
     /** $column.columnComment */

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

@@ -13,7 +13,7 @@ import java.util.Date;
  */
 
 /**
- * 到处出入库统计
+ * 出入库统计
  */
 public class WarhousrExcel {
     private static final long serialVersionUID = 1L;

+ 8 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.java

@@ -2,10 +2,7 @@ package com.ruoyi.warehouseBusiness.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ruoyi.anpin.ProfitExcel;
-import com.ruoyi.anpin.SalesOfOutbound;
-import com.ruoyi.anpin.TMonthEndingClosingExcel;
-import com.ruoyi.anpin.WarhousrExcel;
+import com.ruoyi.anpin.*;
 import com.ruoyi.finance.excel.FleetExcel;
 import com.ruoyi.shipping.domain.TAccount;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
@@ -189,4 +186,11 @@ public interface TWarehousebillsfeesMapper extends BaseMapper<TWarehousebillsfee
      * @return
      */
     public List<TMonthEndingClosingExcel> selectTMonthEndingClosingList(@Param("fYear") int fYear,@Param("fMonth") int fMonth,@Param("fStatus") String fStatus);
+
+    /**
+     * 查询库存总账
+     * @param tWarehouseBills
+     * @return
+     */
+    public List<InventoryLedgerExcel> selectInventoryLedger(TWarehouseBills tWarehouseBills);
 }

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

@@ -1,5 +1,6 @@
 package com.ruoyi.warehouseBusiness.service;
 
+import com.ruoyi.anpin.InventoryLedgerExcel;
 import com.ruoyi.anpin.ProfitExcel;
 import com.ruoyi.anpin.SalesOfOutbound;
 import com.ruoyi.anpin.WarhousrExcel;
@@ -501,4 +502,10 @@ public interface ITWarehouseBillsService {
      * @return
      */
     public List<ProfitExcel> salectAnpinProfit(TWarehouseBills tWarehouseBills);
+    /**
+     * 安品查询库存总账
+     * @param tWarehouseBills
+     * @return
+     */
+    public List<InventoryLedgerExcel> selectInventoryLedger(TWarehouseBills tWarehouseBills);
 }

+ 70 - 6
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -6,10 +6,7 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.ruoyi.anpin.ProfitExcel;
-import com.ruoyi.anpin.SalesOfOutbound;
-import com.ruoyi.anpin.TMonthEndingClosingExcel;
-import com.ruoyi.anpin.WarhousrExcel;
+import com.ruoyi.anpin.*;
 import com.ruoyi.approvalFlow.domain.AuditItems;
 import com.ruoyi.approvalFlow.mapper.AuditItemsMapper;
 import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
@@ -1627,6 +1624,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             i = tWarehouseBillsMapper.insertTWarehousebills(warehouseBills);
             if (CollectionUtils.isNotEmpty(warehousebillsfeesList)) {
                 for (TWarehousebillsfees warehousebillsfees : warehousebillsfeesList) {
+                    AjaxResult ajaxResult = this.goodsAttribute(warehousebillsfees,billsType);
+                    String code = ajaxResult.get("code").toString();
+                    if ("500".equals(code)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ajaxResult;
+                    }
                     warehousebillsfees.setfPid(warehouseBills.getfId());
                     warehousebillsfees.setCreateTime(DateUtils.getNowDate());
                     warehousebillsfees.setCreateBy(SecurityUtils.getUsername());
@@ -1660,6 +1663,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             //i = tWarehousebillsfeesMapper.deleteByFPid(warehouseBills.getfId());
             if (CollectionUtils.isNotEmpty(warehousebillsfeesList)) {
                 for (TWarehousebillsfees warehousebillsfees : warehousebillsfeesList) {
+                    AjaxResult ajaxResult = this.goodsAttribute(warehousebillsfees,billsType);
+                    String ajaxResultCode = ajaxResult.get("code").toString();
+                    if ("500".equals(ajaxResultCode)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ajaxResult;
+                    }
                     if (warehousebillsfees.getfId() == null){
                         warehousebillsfees.setfPid(warehouseBills.getfId());
                         warehousebillsfees.setCreateTime(DateUtils.getNowDate());
@@ -1754,7 +1763,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             List<TMonthEndingClosingExcel> tMonthEndingClosingExcel = tWarehousebillsfeesMapper.selectTMonthEndingClosingList(year, month+1, "T");
             if (CollectionUtils.isNotEmpty(tMonthEndingClosingExcel)){
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return AjaxResult.error("当前入库日期所在的年月已结账不能入账");
+                return AjaxResult.error("当前入库日期"+year+"年"+(month+1)+"月"+"所在的年月已结账不能入账");
             }
         }
         if (warehouseBills.getfId() == null) {
@@ -1771,6 +1780,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             i = tWarehouseBillsMapper.insertTWarehousebills(warehouseBills);
             if (CollectionUtils.isNotEmpty(warehousebillsfeesList)) {
                 for (TWarehousebillsfees warehousebillsfees : warehousebillsfeesList) {
+                    AjaxResult ajaxResult = this.goodsAttribute(warehousebillsfees,billsType);
+                    String code = ajaxResult.get("code").toString();
+                    if ("500".equals(code)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ajaxResult;
+                    }
                     warehousebillsfees.setfPid(warehouseBills.getfId());
                     warehousebillsfees.setCreateTime(DateUtils.getNowDate());
                     warehousebillsfees.setCreateBy(SecurityUtils.getUsername());
@@ -1785,6 +1800,26 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         warehousebillsfees.setfBsdate(warehouseBills.getfBsdate());
                     }
                     i = tWarehousebillsfeesMapper.insertTWarehousebillsfees(warehousebillsfees);
+                    //出库入库生成库存总账
+                    if ("RK".equals(billsType)){
+                        TWhgenleg tWhgenleg = this.anPinQueryTWhgenleg(warehouseBills, warehousebillsfees);
+                        if (tWhgenleg == null){
+                            this.anPinInstalTWhgenleg(warehouseBills,warehousebillsfees,loginUser.getUser());
+                        }else {
+                            this.anPinUpdateTWhgenlegData(warehousebillsfees,tWhgenleg.getfId(),billsType);
+                        }
+                    }
+                    if ("CK".equals(billsType)){
+                        TWhgenleg tWhgenleg = this.anPinQueryTWhgenleg(warehouseBills, warehousebillsfees);
+                        if (tWhgenleg == null){
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return AjaxResult.error("出库数量大于库存数,库存不足");
+                        }else if (tWhgenleg.getfId() != null && tWhgenleg.getfGrossweightblc().compareTo(warehousebillsfees.getfQty())< 0){
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return AjaxResult.error("出库数量大于库存数,库存不足");
+                        }
+                        this.anPinUpdateTWhgenlegData(warehousebillsfees,tWhgenleg.getfId(),billsType);
+                    }
                 }
             }
             fPid = warehouseBills.getfId();
@@ -1811,6 +1846,12 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             //i = tWarehousebillsfeesMapper.deleteByFPid(warehouseBills.getfId());
             if (CollectionUtils.isNotEmpty(warehousebillsfeesList)) {
                 for (TWarehousebillsfees warehousebillsfees : warehousebillsfeesList) {
+                    AjaxResult ajaxResult = this.goodsAttribute(warehousebillsfees,billsType);
+                    String ajaxResultCode = ajaxResult.get("code").toString();
+                    if ("500".equals(ajaxResultCode)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return ajaxResult;
+                    }
                     warehousebillsfees.setfBillstatus(fBillstatus);
                     if (warehousebillsfees.getfId() == null){
                         warehousebillsfees.setfPid(warehouseBills.getfId());
@@ -1850,7 +1891,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         if (tWhgenleg == null){
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("出库数量大于库存数,库存不足");
-                        }else if (tWhgenleg != null && tWhgenleg.getfGrossweightblc().compareTo(warehousebillsfees.getfQty())< 0){
+                        }else if (tWhgenleg.getfId() != null && tWhgenleg.getfGrossweightblc().compareTo(warehousebillsfees.getfQty())< 0){
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return AjaxResult.error("出库数量大于库存数,库存不足");
                         }
@@ -2035,6 +2076,11 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         return collect;
     }
 
+    @Override
+    public List<InventoryLedgerExcel> selectInventoryLedger(TWarehouseBills tWarehouseBills) {
+        return tWarehousebillsfeesMapper.selectInventoryLedger(tWarehouseBills);
+    }
+
     /**
      * app仓储新行提交业务
      *
@@ -4381,5 +4427,23 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         tWhgenleg.setfWarehouseLocationid(warehousebillsitems.getfWarehouseid());
         return tWhgenlegMapper.selectTWhgenleg(tWhgenleg);
     }
+    //判断入库属性是否为空
+    public AjaxResult goodsAttribute(TWarehousebillsfees tWarehousebillsfees, String billsType){
+        if (tWarehousebillsfees.getfFeeid() == null){
+            return AjaxResult.error("品名不能为空");
+        }else if (tWarehousebillsfees.getfQty() == null){
+            return AjaxResult.error("数量不能为空");
+        }else if (tWarehousebillsfees.getfUnitprice() == null){
+            return AjaxResult.error("单价不能为空");
+        }else if (tWarehousebillsfees.getfFeeunitid() == null){
+            return AjaxResult.error("计价单位不能为空");
+        }else if (tWarehousebillsfees.getfWarehouseid() == null && billsType.equals("RK")){
+            return AjaxResult.error("库区不能为空");
+        }else if (tWarehousebillsfees.getfWarehouseid() == null && billsType.equals("CK")){
+            return AjaxResult.error("库区不能为空");
+        }else {
+            return AjaxResult.success();
+        }
+    }
 
 }

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

@@ -2298,6 +2298,7 @@
     </select>
     <select id="selectAnPinList" parameterType="TWarehousebills" resultMap="TWarehousebillsResult">
         SELECT
+        DISTINCT
         tw.f_id,
         tw.f_billno,
         tw.f_customsdeclartion,
@@ -2406,16 +2407,21 @@
         tw.f_students_weight,
         th.f_name AS fWarehouseName,
         tw.f_market_typid,
-        tw.f_purchase
+        tw.f_purchase,
+        tr.f_name    AS fsbuName
         FROM
         t_warehousebills tw
         LEFT JOIN t_project tp
         ON tw.f_goodsid = tp.f_id
         LEFT JOIN t_corps tc
         ON tw.f_corpid = tc.f_id
+        LEFT JOIN t_corps tr
+        ON tr.f_id = tw.f_sbu
         LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
+        LEFT JOIN t_warehousebillsfees tb ON tb.f_pid = tw.f_id
         <where>
             tw.del_flag = '0'
+            <if test="fFeeid != null ">and tb.f_feeid = #{fFeeid}</if>
             <if test="fBillno != null  and fBillno != ''">and tw.f_billno = #{fBillno}</if>
             <if test="fCustomsdeclartion != null  and fCustomsdeclartion != ''">and tw.f_customsdeclartion =
                 #{fCustomsdeclartion}
@@ -2458,7 +2464,6 @@
             <if test="fBilltype != null  and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
             <if test="fBillstatus != null ">and tw.f_billstatus = #{fBillstatus}</if>
             <if test="fItemsStatus != null ">and tw.f_items_status = #{fItemsStatus}</if>
-            <if test="delFlag != null">and tw.del_flag = #{delFlag},</if>
             <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
             <if test="fProductName != null  and fProductName != ''">and tw.f_product_name like concat('%',
                 #{fProductName},

+ 111 - 9
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -1076,7 +1076,8 @@
         sc.dict_label AS ffeeunitidName,/*计价单位中文名*/
         td.fqty AS fqty,/*数量*/
         td.famount AS famount,/*金额*/
-        round(td.price,2) AS price/*单价*/
+        round(td.price,2) AS price,/*单价*/
+        td.fBsdate AS fBsdate/*入库日期*/
         FROM
         (
         SELECT
@@ -1085,6 +1086,7 @@
         tc.fname,
         tc.fcurrency,
         tc.ffeeunitid,
+        tc.fBsdate,
         IFNULL( SUM( tc.fqty ), 0 ) fqty,
         IFNULL( SUM( tc.famount ), 0 ) famount,
         IFNULL( SUM( tc.famount )/ SUM( tc.fqty ), 0 ) price
@@ -1103,8 +1105,8 @@
         /*计价单位*/
         tw.f_qty fqty,
         /*实际数量*/
-        tw.f_amount famount /*金额*/
-
+        tw.f_amount famount, /*金额*/
+        tw.f_bsdate fBsdate/*出库日期*/
         FROM
         t_warehousebillsfees tw
         LEFT JOIN t_warehousebills tb ON tw.f_pid = tb.f_id
@@ -1129,12 +1131,13 @@
         tc.ffeetype,
         tc.fname,
         tc.fcurrency,
-        tc.ffeeunitid
+        tc.ffeeunitid,
+        tc.fBsdate
         ) td
         LEFT JOIN t_project tp ON td.fgoodsid = tp.f_id
         LEFT JOIN sys_dict_data sc ON sc.dict_value = td.ffeeunitid AND sc.dict_type = 'data_unitfees'
         LEFT JOIN sys_dict_data si ON si.dict_value = td.ffeetype AND si.dict_type = 'data_cost_attribute'
-        ORDER BY td.fgoodsid DESC
+        ORDER BY td.fBsdate DESC, td.fgoodsid DESC
     </select>
     <!--安品利润统计-->
     <select id="salectAnpinProfit" parameterType="TWarehousebills"
@@ -1184,10 +1187,10 @@
         <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{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]!= ""'>
+        <if test="monthList != null and monthList[0] != null and monthList[0]!= ''">
             and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
         </if>
-        <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
+        <if test="monthList != null and monthList[1] != null and monthList[1]!= ''">
             and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
         </if>
         GROUP BY
@@ -1303,10 +1306,10 @@
         <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{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]!= ""'>
+        <if test='monthList != null and monthList[0] != null and monthList[0]!= "" '>
             and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
         </if>
-        <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
+        <if test='monthList != null and monthList[1] != null and monthList[1]!= "" '>
             and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
         </if>
         GROUP BY
@@ -1334,4 +1337,103 @@
         </where>
         ORDER BY f_year,f_month
     </select>
+    <!--安品库存总账-->
+    <select id="selectInventoryLedger" parameterType="TWarehousebills" resultType="com.ruoyi.anpin.InventoryLedgerExcel">
+        SELECT
+        DATE_FORMAT( tf.f_bsdate, '%Y' ) AS fyears,
+        /*年*/
+        DATE_FORMAT( tf.f_bsdate, '%m' ) AS fmonth,
+        /*月*/
+        tf.f_corpid AS fCorpid,
+        /*供应商*/
+        tc.f_name AS fCorpName,
+        /*供应商名称*/
+        tf.f_feeid AS fFeeid,
+        /*货物id*/
+        te.f_name AS fFName,
+        /*货物名称*/
+        te.f_currency AS fCurrency,
+        /*规格*/
+        te.f_feetype AS feetype,
+        /*类别*/
+        si.dict_label AS feetypeName,
+        /*类别名称*/
+        tf.f_feeUnitid AS fFeeUnitid,
+        /*计价单位*/
+        sc.dict_label AS feeUnitName,
+        /*计价单位名称*/
+        tf.f_warehouseid AS fWarehouseid,
+        /*库区*/
+        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,
+        /*期初数量*/
+        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 )),
+        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&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS rQty,
+        /*入库数量*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS cQty,
+        /*出库数量*/
+        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_amount ELSE 0 END ),0) AS rfAmount,
+        /*入库金额*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ),0) AS cfAmount,
+        /*出库金额*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype = 'CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS fAfterQty,
+        /*结余数量*/
+        ROUND(
+        IFNULL((
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ))/(
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END )),
+        0
+        ),
+        2
+        ) AS fAfterUnitprice,
+        /*结余单价*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ),0) AS fAfterAmount /*结余金额*/
+
+        FROM
+        t_warehousebillsfees tf
+        LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
+        LEFT JOIN t_warehouse th ON tf.f_warehouseid = th.f_id
+        LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
+        LEFT JOIN t_corps tc ON tf.f_corpid = tc.f_id
+        LEFT JOIN sys_dict_data sc ON sc.dict_value = tf.f_feeUnitid
+        AND sc.dict_type = 'data_unitfees'
+        LEFT JOIN sys_dict_data si ON si.dict_value = te.f_feetype
+        AND si.dict_type = 'data_cost_attribute'
+        WHERE
+        tf.f_billtype IN ( 'RK', 'CK' )
+        AND tf.del_flag = '0'
+        AND tw.del_flag = '0'
+        AND tf.f_bsdate&lt;=#{timeInterval[1]}
+        <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
+        <if test="fBillstatus != null">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fBillstatus == null">and tf.f_billstatus = 6 </if>
+        <if test="fCorpid != null ">and tf.f_corpid = #{fCorpid}</if>
+        <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
+        <if test="feeName != null and feeName != ''">and tf.f_feeid = #{feeName}</if>
+        GROUP BY
+        DATE_FORMAT( tf.f_bsdate, '%Y' ),
+        DATE_FORMAT( tf.f_bsdate, '%m' ),
+        tf.f_corpid,
+        tf.f_feeid,
+        te.f_currency,
+        tf.f_feeUnitid,
+        tf.f_warehouseid,
+        te.f_feetype
+        ORDER BY
+        DATE_FORMAT( tf.f_bsdate, '%Y' ),
+        DATE_FORMAT( tf.f_bsdate, '%m' ),
+        CONVERT (
+        te.f_name USING GBK)
+    </select>
 </mapper>

BIN
ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsfeesMapper.class


BIN
ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.class


BIN
ruoyi-warehouse/target/classes/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.class


+ 7 - 2
ruoyi-warehouse/target/classes/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -2298,6 +2298,7 @@
     </select>
     <select id="selectAnPinList" parameterType="TWarehousebills" resultMap="TWarehousebillsResult">
         SELECT
+        DISTINCT
         tw.f_id,
         tw.f_billno,
         tw.f_customsdeclartion,
@@ -2406,16 +2407,21 @@
         tw.f_students_weight,
         th.f_name AS fWarehouseName,
         tw.f_market_typid,
-        tw.f_purchase
+        tw.f_purchase,
+        tr.f_name    AS fsbuName
         FROM
         t_warehousebills tw
         LEFT JOIN t_project tp
         ON tw.f_goodsid = tp.f_id
         LEFT JOIN t_corps tc
         ON tw.f_corpid = tc.f_id
+        LEFT JOIN t_corps tr
+        ON tr.f_id = tw.f_sbu
         LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
+        LEFT JOIN t_warehousebillsfees tb ON tb.f_pid = tw.f_id
         <where>
             tw.del_flag = '0'
+            <if test="fFeeid != null ">and tb.f_feeid = #{fFeeid}</if>
             <if test="fBillno != null  and fBillno != ''">and tw.f_billno = #{fBillno}</if>
             <if test="fCustomsdeclartion != null  and fCustomsdeclartion != ''">and tw.f_customsdeclartion =
                 #{fCustomsdeclartion}
@@ -2458,7 +2464,6 @@
             <if test="fBilltype != null  and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
             <if test="fBillstatus != null ">and tw.f_billstatus = #{fBillstatus}</if>
             <if test="fItemsStatus != null ">and tw.f_items_status = #{fItemsStatus}</if>
-            <if test="delFlag != null">and tw.del_flag = #{delFlag},</if>
             <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
             <if test="fProductName != null  and fProductName != ''">and tw.f_product_name like concat('%',
                 #{fProductName},

+ 112 - 9
ruoyi-warehouse/target/classes/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -1076,7 +1076,8 @@
         sc.dict_label AS ffeeunitidName,/*计价单位中文名*/
         td.fqty AS fqty,/*数量*/
         td.famount AS famount,/*金额*/
-        round(td.price,2) AS price/*单价*/
+        round(td.price,2) AS price,/*单价*/
+        td.fBsdate AS fBsdate/*入库日期*/
         FROM
         (
         SELECT
@@ -1085,6 +1086,7 @@
         tc.fname,
         tc.fcurrency,
         tc.ffeeunitid,
+        tc.fBsdate,
         IFNULL( SUM( tc.fqty ), 0 ) fqty,
         IFNULL( SUM( tc.famount ), 0 ) famount,
         IFNULL( SUM( tc.famount )/ SUM( tc.fqty ), 0 ) price
@@ -1103,8 +1105,8 @@
         /*计价单位*/
         tw.f_qty fqty,
         /*实际数量*/
-        tw.f_amount famount /*金额*/
-
+        tw.f_amount famount, /*金额*/
+        tw.f_bsdate fBsdate/*出库日期*/
         FROM
         t_warehousebillsfees tw
         LEFT JOIN t_warehousebills tb ON tw.f_pid = tb.f_id
@@ -1129,12 +1131,13 @@
         tc.ffeetype,
         tc.fname,
         tc.fcurrency,
-        tc.ffeeunitid
+        tc.ffeeunitid,
+        tc.fBsdate
         ) td
         LEFT JOIN t_project tp ON td.fgoodsid = tp.f_id
         LEFT JOIN sys_dict_data sc ON sc.dict_value = td.ffeeunitid AND sc.dict_type = 'data_unitfees'
         LEFT JOIN sys_dict_data si ON si.dict_value = td.ffeetype AND si.dict_type = 'data_cost_attribute'
-        ORDER BY td.fgoodsid DESC
+        ORDER BY td.fBsdate DESC, td.fgoodsid DESC
     </select>
     <!--安品利润统计-->
     <select id="salectAnpinProfit" parameterType="TWarehousebills"
@@ -1184,10 +1187,10 @@
         <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{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]!= ""'>
+        <if test="monthList != null and monthList[0] != null and monthList[0]!= ''">
             and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
         </if>
-        <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
+        <if test="monthList != null and monthList[1] != null and monthList[1]!= ''">
             and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
         </if>
         GROUP BY
@@ -1303,10 +1306,10 @@
         <if test="fGoodsid != null  and fGoodsid != ''">and tw.f_goodsid = #{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]!= ""'>
+        <if test='monthList != null and monthList[0] != null and monthList[0]!= "" '>
             and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
         </if>
-        <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
+        <if test='monthList != null and monthList[1] != null and monthList[1]!= "" '>
             and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
         </if>
         GROUP BY
@@ -1324,6 +1327,7 @@
         ) AS temp
         ORDER BY temp.years,temp.months,CONVERT(temp.fCorpName USING GBK)
     </select>
+    <!--查询入库日期所在年月是否结账-->
     <select id="selectTMonthEndingClosingList" parameterType="object" resultType="com.ruoyi.anpin.TMonthEndingClosingExcel">
         select f_id, f_year, f_month, f_start, f_enf, f_status from t_month_ending_closing
         <where>
@@ -1333,4 +1337,103 @@
         </where>
         ORDER BY f_year,f_month
     </select>
+    <!--安品库存总账-->
+    <select id="selectInventoryLedger" parameterType="TWarehousebills" resultType="com.ruoyi.anpin.InventoryLedgerExcel">
+        SELECT
+        DATE_FORMAT( tf.f_bsdate, '%Y' ) AS fyears,
+        /*年*/
+        DATE_FORMAT( tf.f_bsdate, '%m' ) AS fmonth,
+        /*月*/
+        tf.f_corpid AS fCorpid,
+        /*供应商*/
+        tc.f_name AS fCorpName,
+        /*供应商名称*/
+        tf.f_feeid AS fFeeid,
+        /*货物id*/
+        te.f_name AS fFName,
+        /*货物名称*/
+        te.f_currency AS fCurrency,
+        /*规格*/
+        te.f_feetype AS feetype,
+        /*类别*/
+        si.dict_label AS feetypeName,
+        /*类别名称*/
+        tf.f_feeUnitid AS fFeeUnitid,
+        /*计价单位*/
+        sc.dict_label AS feeUnitName,
+        /*计价单位名称*/
+        tf.f_warehouseid AS fWarehouseid,
+        /*库区*/
+        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,
+        /*期初数量*/
+        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 )),
+        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&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS rQty,
+        /*入库数量*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS cQty,
+        /*出库数量*/
+        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_amount ELSE 0 END ),0) AS rfAmount,
+        /*入库金额*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ),0) AS cfAmount,
+        /*出库金额*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype = 'CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS fAfterQty,
+        /*结余数量*/
+        ROUND(
+        IFNULL((
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ))/(
+        sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END )),
+        0
+        ),
+        2
+        ) AS fAfterUnitprice,
+        /*结余单价*/
+        IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) - sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ),0) AS fAfterAmount /*结余金额*/
+
+        FROM
+        t_warehousebillsfees tf
+        LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
+        LEFT JOIN t_warehouse th ON tf.f_warehouseid = th.f_id
+        LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
+        LEFT JOIN t_corps tc ON tf.f_corpid = tc.f_id
+        LEFT JOIN sys_dict_data sc ON sc.dict_value = tf.f_feeUnitid
+        AND sc.dict_type = 'data_unitfees'
+        LEFT JOIN sys_dict_data si ON si.dict_value = te.f_feetype
+        AND si.dict_type = 'data_cost_attribute'
+        WHERE
+        tf.f_billtype IN ( 'RK', 'CK' )
+        AND tf.del_flag = '0'
+        AND tw.del_flag = '0'
+        AND tf.f_bsdate&lt;=#{timeInterval[1]}
+        <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
+        <if test="fBillstatus != null">and tf.f_billstatus = #{fBillstatus}</if>
+        <if test="fBillstatus == null">and tf.f_billstatus = 6 </if>
+        <if test="fCorpid != null ">and tf.f_corpid = #{fCorpid}</if>
+        <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
+        <if test="feeName != null and feeName != ''">and tf.f_feeid = #{feeName}</if>
+        GROUP BY
+        DATE_FORMAT( tf.f_bsdate, '%Y' ),
+        DATE_FORMAT( tf.f_bsdate, '%m' ),
+        tf.f_corpid,
+        tf.f_feeid,
+        te.f_currency,
+        tf.f_feeUnitid,
+        tf.f_warehouseid,
+        te.f_feetype
+        ORDER BY
+        DATE_FORMAT( tf.f_bsdate, '%Y' ),
+        DATE_FORMAT( tf.f_bsdate, '%m' ),
+        CONVERT (
+        te.f_name USING GBK)
+    </select>
 </mapper>