From ecb386a4201213c6635f28f9e9e02e3faf217b51 Mon Sep 17 00:00:00 2001
From: yuyou_x <2336760928@qq.com>
Date: 星期六, 16 三月 2024 11:08:34 +0800
Subject: [PATCH] 修改储位图例柱状图以及圆形图显示数据问题。

---
 Wms/WMS.BLL/SysServer/StorageAreaServer.cs |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 103 insertions(+), 7 deletions(-)

diff --git a/Wms/WMS.BLL/SysServer/StorageAreaServer.cs b/Wms/WMS.BLL/SysServer/StorageAreaServer.cs
index 2f5d577..1dc557a 100644
--- a/Wms/WMS.BLL/SysServer/StorageAreaServer.cs
+++ b/Wms/WMS.BLL/SysServer/StorageAreaServer.cs
@@ -2,20 +2,25 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Security.Permissions;
 using System.Text;
 using System.Threading.Tasks;
+using Dm;
 using Model.ModelDto.SysDto;
 using SqlSugar;
+using WMS.DAL;
+using WMS.Entity.Context;
 using WMS.Entity.SysEntity;
 using WMS.IBLL.ISysServer;
 using WMS.IDAL.ISysInterface;
 
 namespace WMS.BLL.SysServer
 {
-    public class StorageAreaServer: IStorageAreaServer
+    public class StorageAreaServer : DbHelper<SysStorageArea>, IStorageAreaServer
     {
+        private static readonly SqlSugarScope Db = DataContext.Db;
         public IStorageAreaRepository AreaRst { get; set; }
-        public StorageAreaServer(IStorageAreaRepository areaRst)
+        public StorageAreaServer(IStorageAreaRepository areaRst) : base(Db)
         {
             AreaRst = areaRst;
         }
@@ -31,7 +36,7 @@
         /// <param name="limit"></param>
         /// <param name="count"></param>
         /// <returns></returns>
-        public List<AreaDto> GetStorageAreaList(string areaName, string wareHouseNo, string status, string type,int page, int limit,out int count)
+        public List<AreaDto> GetStorageAreaList(string areaName, string wareHouseNo, string status, string type, int page, int limit, out int count)
         {
             try
             {
@@ -43,7 +48,7 @@
                     .AndIF(!string.IsNullOrWhiteSpace(type), it => it.Type == type)
                     .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
 
-                
+
                 var data = AreaRst.GetAllByOrderPageAsync(item, limit, page, out int counts)
                     .Includes(x => x.WareHouseInfo)
                     .Includes(x => x.TemperatureInfo)
@@ -92,6 +97,25 @@
                 throw new Exception(e.Message);
             }
         }
+
+        /// <summary>
+        /// 鑾峰彇鍗曟潯搴撳尯鍩熶俊鎭�
+        /// </summary>
+        /// <param name="id">ID</param>
+        /// <returns></returns>
+        public SysStorageArea GetStorageMaxArea()
+        {
+            try
+            {
+                var data = Db.Queryable<SysStorageArea>().Where(a => a.IsDel == "0" && a.WareHouseNo == "W01").OrderByDescending(a => a.CreateTime).First();
+                return data;
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+
         /// <summary>
         /// 鑾峰彇鍖哄煙淇℃伅锛堟牴鎹粨搴撳彿锛�
         /// </summary>
@@ -105,11 +129,83 @@
                 if (!string.IsNullOrWhiteSpace(wareHouseNo))
                 {
                     data = data.Where(m => m.WareHouseNo == wareHouseNo).ToList();
-                } 
+                }
                 return data;
             }
             catch (Exception e)
             {
+                throw new Exception(e.Message);
+            }
+        }
+
+        /// <summary>
+        /// 淇敼搴撳尯鍩熶俊鎭�
+        /// </summary>
+        /// <param name="model">鍖哄煙瀹炰綋</param>
+        /// <returns>鏄惁鎴愬姛</returns>
+        public string InsertStorageArea(SysStorageArea model)
+        {
+            try
+            {
+                string str = "";
+                //鍒ゆ柇鎵�灞炰粨搴撴槸鍚︿负绔嬩綋搴�
+                if (model.WareHouseNo != "W01")
+                {
+                    str = "-1:鎵�灞炰粨搴撲笉涓虹珛浣撳簱锛岃閲嶆柊閫夋嫨锛�";
+                    return str;
+                }
+                //鑾峰彇绔嬩綋搴撴渶澶х紪鐮�
+                //var area = Db.Queryable<SysStorageArea>().Max(a => a.Id)(a => a.IsDel == "0" && a.WareHouseNo == "W01");
+                var area = Db.Queryable<SysStorageArea>().Where(a => a.IsDel == "0" && a.WareHouseNo == "W01").OrderByDescending(a=>a.CreateTime).First();
+                //楠岃瘉鏄惁瀛樺湪绔嬩綋搴撶涓�鏉″尯鍩熶俊鎭�
+                if (area == null)
+                {
+                    model.AreaNo = "A01";
+                }
+                else
+                {
+                    var arr = area.AreaNo.Split("A");
+                    int a = int.Parse(arr[1]) + 1;
+                    //鍒ゆ柇鏄惁灏忎簬10
+                    if (a < 10)
+                    {
+                        model.AreaNo = "A0" + (int.Parse(arr[1]) + 1).ToString();
+                    }
+                    else
+                    {
+                        model.AreaNo = "A" + (int.Parse(arr[1]) + 1).ToString();
+                    }
+
+                }
+                Db.BeginTran();
+
+                //鏂板鍖哄煙淇℃伅
+                SysStorageArea list = new SysStorageArea()
+                {
+                    AreaNo = model.AreaNo, //鍖哄煙缂栫爜
+                    AreaName = model.AreaName, //鍖哄煙鍚嶇О
+                    WareHouseNo = model.WareHouseNo, //鎵�灞炰粨搴�
+                    RoadwayNo = null, //鎵�灞炲贩閬�
+                    Status = model.Status, //鏄惁鍚敤
+                    Priority = model.Priority, //浼樺厛绾�
+                    Type = model.Type, //瀛樺偍绫诲埆
+                    Temperature = model.Temperature, //瀛樺偍鐜
+                    IsDel = "0", //鏄惁鍒犻櫎
+                    CreateUser = model.CreateUser, //鍒涘缓浜�
+                    CreateTime = Db.GetDate(), //鍒涘缓鏃堕棿
+                    UpdateUser = null, //淇敼浜�
+                    UpdateTime = null, //淇敼鏃堕棿
+                };
+                Db.Insertable(list).ExecuteCommand();
+
+                Db.CommitTran();
+
+                str = "娣诲姞鎴愬姛";
+                return str;
+            }
+            catch (Exception e)
+            {
+                Db.RollbackTran();
                 throw new Exception(e.Message);
             }
         }
@@ -171,7 +267,7 @@
         /// <param name="status">鐘舵�� 0 鍚敤 1鍋滅敤</param>
         /// <param name="userId">鎿嶄綔浜篒D</param>
         /// <returns></returns>
-        public bool EditStorageAreaStatus(int id,string status,int userId)
+        public bool EditStorageAreaStatus(int id, string status, int userId)
         {
             try
             {
@@ -200,7 +296,7 @@
                 throw new Exception(e.Message);
             }
         }
-        
+
 
         /// <summary>
         /// 鑾峰彇鍖哄煙绫诲瀷

--
Gitblit v1.8.0