浏览代码

出入库记录增加按日统计的功能。

xian 4 年之前
父节点
当前提交
1fa68cc3af

+ 4 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/InventoryLogService.java

@@ -25,6 +25,10 @@ public interface InventoryLogService {
      */
     PagedResult<InventoryLog> listByInventoryLogId(PageRequest<InventoryLog> pageRequest);
 
+    /** 按日统计数据 */
+    List<InventoryLog> countInventoryByDate(InventoryLog data);
+
+
     /**
      * 修改库存日志
      * @param inventoryLog

+ 5 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/InventoryLogServiceImpl.java

@@ -35,6 +35,11 @@ public class InventoryLogServiceImpl implements InventoryLogService {
     }
 
     @Override
+    public List<InventoryLog> countInventoryByDate(InventoryLog data) {
+        return inventoryLogMapper.countInventoryByDate(data);
+    }
+
+    @Override
     public Integer updateById(InventoryLog inventoryLog) {
         return inventoryLogMapper.updateById(inventoryLog);
     }

+ 3 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/InventoryLogMapper.java

@@ -23,6 +23,9 @@ public interface InventoryLogMapper {
      */
     List<InventoryLog> listByInventoryLogId(InventoryLog inventoryLog);
 
+    /** 按日统计数据 */
+    List<InventoryLog> countInventoryByDate(InventoryLog data);
+
     /**
      * 修改库存日志
      * @param inventoryLog

+ 16 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/inventoryLogMapper.xml

@@ -33,6 +33,22 @@
     from tb_rst_fm_inventory_log
     where log_id = #{logId,jdbcType=INTEGER}
   </select>
+
+  <select id="countInventoryByDate" parameterType="InventoryLog" resultType="InventoryLog">
+    SELECT
+           t.time log_create_time, t.type log_operation_type, SUM(t.num) log_remaining_num
+    FROM (
+         SELECT
+              DATE_FORMAT(log_create_time,'%Y-%m-%d') time, log_remaining_num num, log_operation_type type
+         FROM
+              tb_rst_fm_inventory_log
+         WHERE
+                 log_product_bar = #{logProductBar} and log_warehouse_id = #{logWarehouseId} AND log_quality_type = 1
+         ) t
+    GROUP BY t.time, t.type
+
+  </select>
+
   <select id="listByInventoryLogId" resultMap="BaseResultMap" parameterType="InventoryLog" >
     select
     log_id as logId,

+ 14 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/InventoryController.java

@@ -1,5 +1,6 @@
 package com.iamberry.rst.controllers.pts;
 
+import com.alibaba.fastjson.JSONObject;
 import com.iamberry.rst.core.fm.InventoryInfo;
 import com.iamberry.rst.core.fm.InventoryLog;
 import com.iamberry.rst.core.order.OrderWarehouse;
@@ -153,6 +154,19 @@ public class InventoryController {
     }
 
     /**
+     * 按日统计产品的出入库数量
+     * @return
+     * @throws Exception
+     */
+    @RequiresPermissions("inventory:select:inventory")
+    @RequestMapping("/countInventoryByDate")
+    public ModelAndView countInventoryByDate(InventoryLog inventoryLog) throws Exception {
+        ModelAndView mv = new ModelAndView("cm/inventory/count_inventory");
+        mv.addObject("data", JSONObject.toJSONString(inventoryLogService.countInventoryByDate(inventoryLog)));
+        return mv;
+    }
+
+    /**
      * 获取库存信息
      * @param
      * @return

+ 75 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inventory/count_inventory.ftl

@@ -0,0 +1,75 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+    <meta http-equiv="Cache-Control" content="no-siteapp" />
+    <#include "/base/add_base.ftl">
+
+    <!-- 新增需求引入js、css -->
+    <link href="${path}/common/lib/bootstrap/bootstrap.min.css" rel="stylesheet" />
+    <link rel="stylesheet" type="text/css" href="${path}/common/lib/calendar/calendar-pro.css" />
+    <title>查看产品出入库数据</title>
+</head>
+<body>
+<div class="pd-20 calendar-box" style="margin-left: 5%">
+
+</div>
+<script type="text/javascript" src="${path}/common/lib/calendar/calendar-pro.js"></script>
+<script type="text/javascript">
+    $(function() {
+        // 库存数据
+        let list = ${data!};
+        if (list == null || list.length <= 0) {
+            layer.msg("未查询到数据,请核查",{icon: 5,time:1700});
+            return;
+        }
+        // 初始化插件
+        let adult = new Map();
+        for (let i = 0; i < list.length; i++) {
+            let obj = list[i];
+            let key = formatDate(obj.logCreateTime, "yyyy-MM-dd");
+            console.log(key);
+            if (adult.has(key)) {
+                let t = adult.get(key);
+                if (obj.logOperationType==2) {
+                    // 入库
+                    t.outNum = obj.logRemainingNum;
+                } else {
+                    // 出库
+                    t.inNum = obj.logRemainingNum;
+                }
+                adult.delete(key);
+                adult.set(key, t);
+            } else {
+                let t = {"outNum":0, "inNum":0};
+                if (obj.logOperationType==2) {
+                    // 入库
+                    t.outNum = obj.logRemainingNum;
+                } else {
+                    // 出库
+                    t.inNum = obj.logRemainingNum;
+                }
+                adult.set(key, t);
+            }
+        }
+        let array = new Array();
+        let i = 0;
+        adult.forEach(function (value, key, map) {
+            let temp = {};
+            temp["date"] = key;
+            temp["data"] = ("入:" + value.inNum) + " / " + ("出:" + value.outNum);
+            array[i] = temp;
+            i++;
+        });
+        $('.calendar-box').calendar({
+            ele: '.calendar-box',
+            title: '查看产品出入库数据',
+            data: array
+        });
+    });
+</script>
+</body>
+</html>

+ 7 - 3
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inventory/inventory_list.ftl

@@ -118,8 +118,12 @@
                                onclick="update('减少库存','${path}/admin/inventory/to_update_inventory?inventoryId=${info.inventoryId!''}&operationType=1','600','500');">
                                 <i class="Hui-iconfont">出库</i>
                             </a>
+                            <a style="text-decoration:none" href="javascript:;" title="出入库统计"
+                               onclick="getInventoryLog('出入库统计','${path}/admin/inventory/countInventoryByDate?logProductBar=${info.inventoryProductBar!''}&logWarehouseId=${info.warehouseId!''}');">
+                                <i class="Hui-iconfont">出入库统计</i>
+                            </a>
                             <a style="text-decoration:none" href="javascript:;" title="出入库记录"
-                               onclick="getInventoryLog('${path}/admin/inventory/select_inventoryLog_list?logProductBar=${info.inventoryProductBar!''}&logWarehouseId=${info.warehouseId!''}');">
+                               onclick="getInventoryLog('出入库记录',${path}/admin/inventory/select_inventoryLog_list?logProductBar=${info.inventoryProductBar!''}&logWarehouseId=${info.warehouseId!''}');">
                                 <i class="Hui-iconfont">出入库记录</i>
                             </a>
                             </#if>
@@ -142,8 +146,8 @@
     function update(title,url,w,h){
         layer_show(title,url,w,h);
     }
-    function getInventoryLog(url) {
-        location.href = url;
+    function getInventoryLog(title, url) {
+        layer_show(title,url,"800","600");
     }
 
     /*$(function(){

文件差异内容过多而无法显示
+ 1 - 0
watero-rst-web/src/main/webapp/common/lib/calendar/calendar-pro.css


文件差异内容过多而无法显示
+ 178 - 0
watero-rst-web/src/main/webapp/common/lib/calendar/calendar-pro.js


二进制
watero-rst-web/src/main/webapp/common/lib/calendar/img/left-arr.png


二进制
watero-rst-web/src/main/webapp/common/lib/calendar/img/right-arr.png