Kaynağa Gözat

仓库统计管理修复完成

DuGuYang 3 yıl önce
ebeveyn
işleme
243f560f31

+ 82 - 60
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -1454,7 +1454,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 仓库列表
         /// </summary>
         /// <returns></returns>
-        public JsonResult StatDo(string CreateDateData, int page = 1, int limit = 30)
+        public JsonResult StatDo(string MakerCode, string StoreNo, string CreateDateData, int page = 1, int limit = 30)
         {
             OtherMySqlConn.connstr = ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
             string sCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
@@ -1475,6 +1475,15 @@ namespace MySystem.Areas.Admin.Controllers
 
                 return Json(nodata);
             }
+            var condtion = "";
+            if (!string.IsNullOrEmpty(MakerCode))
+            {
+                condtion += "and MakerCode='" + MakerCode + "'";
+            }
+            if (!string.IsNullOrEmpty(StoreNo))
+            {
+                condtion += "and StoreNo='" + StoreNo + "'";
+            }
             string minId = "0";
             string maxId = "0";
             string minPosId = "0";
@@ -1505,33 +1514,35 @@ namespace MySystem.Areas.Admin.Controllers
                     }
                 }
             }
-            DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
-            if (startPosDt.Rows.Count > 0)
-            {
-                minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
-                if (minPosId == "0")
-                {
-                    startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
-                    if (startPosDt.Rows.Count > 0)
-                    {
-                        minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
-                    }
-                }
-            }
-            DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
-            if (endPosDt.Rows.Count > 0)
-            {
-                maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
-                if (maxPosId == "0")
-                {
-                    endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
-                    if (endPosDt.Rows.Count > 0)
-                    {
-                        maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
-                    }
-                }
-            }
-            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where c1>0 or c2>0 or c3>0");
+            // DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            // if (startPosDt.Rows.Count > 0)
+            // {
+            //     minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+            //     if (minPosId == "0")
+            //     {
+            //         startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+            //         if (startPosDt.Rows.Count > 0)
+            //         {
+            //             minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+            //         }
+            //     }
+            // }
+            // DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            // if (endPosDt.Rows.Count > 0)
+            // {
+            //     maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+            //     if (maxPosId == "0")
+            //     {
+            //         endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+            //         if (endPosDt.Rows.Count > 0)
+            //         {
+            //             maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+            //         }
+            //     }
+            // }
+            // DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where (c1>0 or c2>0 or c3>0) " + condtion);
+
+            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.MakerCode,u.RealName,u.Mobile,s.ManageMobile,s.Address,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1, (select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2, (select ActCount from KxsStatServer.StoreAct202211 where StoreId=s.Id) as c3, ua.FixedAmount, ua.ValidAmount, ua.TempAmount, (select sum(PromissAmount) from StoreHouseAmountPromiss where ToUserId=s.UserId and `Status`=1) as PromissAmount from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id left join UserAccount ua on s.UserId=ua.Id) tb where (c1>0 or c2>0 or c3>0)" + condtion + "");
 
             int recordcount = list.Rows.Count;
             List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
@@ -1567,7 +1578,7 @@ namespace MySystem.Areas.Admin.Controllers
         /// 导出Excel
         /// </summary>
         /// <returns></returns>
-        public JsonResult StatExportExcel(string CreateDateData)
+        public JsonResult StatExportExcel(string MakerCode, string StoreNo, string CreateDateData)
         {
             OtherMySqlConn.connstr = ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
             string sCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
@@ -1590,7 +1601,7 @@ namespace MySystem.Areas.Admin.Controllers
                 NoDataReturnFields.Add("Mobile", "仓库所属人手机号");
                 NoDataReturnFields.Add("RealName", "仓库所属人名称");
                 NoDataReturnFields.Add("MakerCode", "仓库所属人编码");
-                NoDataReturnFields.Add("ManageMakerCode", "仓库管理员编码");
+                // NoDataReturnFields.Add("ManageMakerCode", "仓库管理员编码");
                 NoDataReturnFields.Add("Name", "品牌");
                 NoDataReturnFields.Add("LaveNum", "当前库存");
                 NoDataReturnFields.Add("c1", "出库(调拨)量");
@@ -1599,6 +1610,16 @@ namespace MySystem.Areas.Admin.Controllers
                 nodata.Add("Fields", NoDataReturnFields);
                 return Json(nodata);
             }
+
+            var condtion = "";
+            if (!string.IsNullOrEmpty(MakerCode))
+            {
+                condtion += "and MakerCode='" + MakerCode + "'";
+            }
+            if (!string.IsNullOrEmpty(StoreNo))
+            {
+                condtion += "and StoreNo='" + StoreNo + "'";
+            }
             string minId = "0";
             string maxId = "0";
             string minPosId = "0";
@@ -1629,34 +1650,35 @@ namespace MySystem.Areas.Admin.Controllers
                     }
                 }
             }
-            DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
-            if (startPosDt.Rows.Count > 0)
-            {
-                minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
-                if (minPosId == "0")
-                {
-                    startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
-                    if (startPosDt.Rows.Count > 0)
-                    {
-                        minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
-                    }
-                }
-            }
-            DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
-            if (endPosDt.Rows.Count > 0)
-            {
-                maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
-                if (maxPosId == "0")
-                {
-                    endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
-                    if (endPosDt.Rows.Count > 0)
-                    {
-                        maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
-                    }
-                }
-            }
-            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,u.MakerCode,(select MakerCode from Users where Id=s.ManageUserId) as ManageMakerCode,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where c1>0 or c2>0 or c3>0");
-
+            // DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            // if (startPosDt.Rows.Count > 0)
+            // {
+            //     minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+            //     if (minPosId == "0")
+            //     {
+            //         startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+            //         if (startPosDt.Rows.Count > 0)
+            //         {
+            //             minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+            //         }
+            //     }
+            // }
+            // DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            // if (endPosDt.Rows.Count > 0)
+            // {
+            //     maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+            //     if (maxPosId == "0")
+            //     {
+            //         endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+            //         if (endPosDt.Rows.Count > 0)
+            //         {
+            //             maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+            //         }
+            //     }
+            // }
+            // DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where (c1>0 or c2>0 or c3>0) " + condtion);
+
+            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.MakerCode,u.RealName,u.Mobile,s.ManageMobile,s.Address,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1, (select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2, (select ActCount from KxsStatServer.StoreAct202211 where StoreId=s.Id) as c3, ua.FixedAmount, ua.ValidAmount, ua.TempAmount, (select sum(PromissAmount) from StoreHouseAmountPromiss where ToUserId=s.UserId and `Status`=1) as PromissAmount from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id left join UserAccount ua on s.UserId=ua.Id) tb where (c1>0 or c2>0 or c3>0)" + condtion + "");
             int recordcount = list.Rows.Count;
             List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
             foreach (DataRow sub in list.Rows)
@@ -1667,7 +1689,7 @@ namespace MySystem.Areas.Admin.Controllers
                 row.Add("Mobile", sub["Mobile"].ToString());
                 row.Add("RealName", sub["RealName"].ToString());
                 row.Add("MakerCode", sub["MakerCode"].ToString());
-                row.Add("ManageMakerCode", sub["ManageMakerCode"].ToString());
+                // row.Add("ManageMakerCode", sub["ManageMakerCode"].ToString());
                 row.Add("Name", sub["Name"].ToString());
                 row.Add("LaveNum", sub["LaveNum"].ToString());
                 row.Add("c1", sub["c1"].ToString());
@@ -1686,7 +1708,7 @@ namespace MySystem.Areas.Admin.Controllers
             ReturnFields.Add("Mobile", "仓库所属人手机号");
             ReturnFields.Add("RealName", "仓库所属人名称");
             ReturnFields.Add("MakerCode", "仓库所属人编码");
-            ReturnFields.Add("ManageMakerCode", "仓库管理员编码");
+            // ReturnFields.Add("ManageMakerCode", "仓库管理员编码");
             ReturnFields.Add("Name", "品牌");
             ReturnFields.Add("LaveNum", "当前库存");
             ReturnFields.Add("c1", "出库(调拨)量");

+ 23 - 25
Areas/Admin/Views/MainServer/StoreHouse/Stat.cshtml

@@ -3,64 +3,60 @@
     string right = ViewBag.right as string;
     string MakerCode = ViewBag.MakerCode as string;
 
-    
+
 }
 <!DOCTYPE html>
 <html>
+
 <head>
     <meta charset="utf-8">
     <title>仓库</title>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
     <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
     <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
     <script src="/admin/js/jquery-1.10.1.min.js"></script>
     <style>
-        .layui-input-inline{
+        .layui-input-inline {
             width: 175px !important;
         }
-        .layui-form-label{
+
+        .layui-form-label {
             width: 128px !important;
         }
-        .layui-inline{
+
+        .layui-inline {
             margin-right: 0px !important;
         }
-        .w100{
+
+        .w100 {
             width: 100px !important;
         }
-        .ml50{
+
+        .ml50 {
             margin-left: 50px !important;
         }
     </style>
 </head>
+
 <body>
     <div class="layui-fluid">
         <div class="layui-card">
             <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                 <div class="layui-form-item">
                     <div class="layui-inline">
-                            <label class="layui-form-label">创客编号</label>
-                            <div class="layui-input-inline">
-                                <input class="layui-input" type="text" name="MakerCode" value="@MakerCode" autocomplete="off">
-                            </div>
-                        </div>
-                        <div class="layui-inline">
-                            <label class="layui-form-label">创客名称</label>
-                            <div class="layui-input-inline">
-                                <input class="layui-input" type="text" name="RealName" autocomplete="off">
-                            </div>
-                        </div>
-                    <div class="layui-inline">
-                        <label class="layui-form-label">仓库编号</label>
+                        <label class="layui-form-label">创客编号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="StoreNo" placeholder="" autocomplete="off">
+                            <input class="layui-input" type="text" name="MakerCode" value="@MakerCode"
+                                autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
-                        <label class="layui-form-label">仓库名称</label>
+                        <label class="layui-form-label">仓库编号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="StoreName" placeholder="" autocomplete="off">
+                            <input class="layui-input" type="text" name="StoreNo" placeholder="" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
@@ -83,8 +79,9 @@
 
             <div class="layui-card-body">
                 <div style="padding-bottom: 10px;">
-                    <button class="layui-btn" data-type="ExportExcel"><i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
-                </div>                
+                    <button class="layui-btn" data-type="ExportExcel"><i
+                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+                </div>
                 <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
             </div>
         </div>
@@ -96,4 +93,5 @@
         var MakerCode = '@MakerCode';
     </script>
 </body>
+
 </html>