From 1483d0e74b4dde9eb22e022276390bfa1f24495b Mon Sep 17 00:00:00 2001
From: hudong <Administrator@PC-20250329JZUF>
Date: 星期五, 30 五月 2025 08:58:53 +0800
Subject: [PATCH] wsdl文件替换 大屏接口开发

---
 api/WmsSapController.cs |  147 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 1 deletions(-)

diff --git a/api/WmsSapController.cs b/api/WmsSapController.cs
index a504c9e..ea23188 100644
--- a/api/WmsSapController.cs
+++ b/api/WmsSapController.cs
@@ -17,11 +17,156 @@
 using static HH.WCS.Mobox3.pinggao.api.OtherModel;
 using static HH.WCS.Mobox3.pinggao.api.ApibackModel;
 using HH.WCS.Mobox3.pinggao.models;
+using static HH.WCS.Mobox3.pinggao.models.DAPING;
+using HH.WCS.Mobox3.pinggao.util;
+using SqlSugar;
 
 namespace HH.WCS.Mobox3.pinggao.api
 {
     public class WmsSapController : System.Web.Http.ApiController
     {
+
+        #region 澶у睆鏁版嵁鎺ュ彛
+        /// <summary>
+        /// 澶у睆鏁版嵁
+        /// </summary>
+        /// <returns></returns>
+        public BarChartResponse InOut(){
+
+            var response = new BarChartResponse
+            {
+                OutboundData = new List<BarChartData>
+                {
+                },
+                InboundData = new List<BarChartData>
+                {
+
+                },
+                CKNData = new List<NB> { },
+                ListTask = new List<Tasks> { },
+                Inttbounddjcount = 0,
+                Outtbounddjcount=0,
+                IntodayCount = 0,
+                OuttodayCount = 0
+
+            };
+
+            var db = new SqlHelper<object>().GetInstance();
+            #region 鍑哄簱
+            // 1. 鑾峰彇褰撳墠骞翠唤锛堟垨鎸囧畾骞翠唤锛�+            int year = DateTime.Now.Year; // 濡�023
+
+            // 2. 鐢熸垚1-12鏈堟墍鏈夋湀浠斤紙纭繚瀹屾暣鎬э級
+            var allMonths = Enumerable.Range(1, 12)
+                .Select(m => new DateTime(year, m, 1).ToString("MM"))
+                .ToList();
+
+            //var allMonths = Enumerable.Range(1, 12).ToList();
+            // 3. 鏌ヨ鏁版嵁搴撹幏鍙栧嚭搴撴暟鎹紙鎸夋湀浠藉垎缁勭粺璁★級
+            var outboundCounts = db.Queryable<WCSTask>()
+                .Where(a => a.S_TYPE.Contains("鍑哄簱") &&a.N_B_STATE==3&& a.T_END_TIME != null&&a.T_END_TIME.Value.Year== year)
+                .ToList() // 鍔犺浇鍒板唴瀛�+                .GroupBy(a => a.T_END_TIME.Value.ToString("MM")) // 鎸夋湀浠藉垎缁�+                .ToDictionary(g => g.Key, g => g.Count()); // 杞负瀛楀吀锛堟湀浠�璁板綍鏁帮級
+
+            // 3. 鏋勫缓瀹屾暣1-12鏈堟暟鎹紙缂哄け鏈堜唤琛�锛�+            var outboundData = allMonths.Select(month => new BarChartData
+            {
+                Month = int.Parse(month),
+                Count = outboundCounts.TryGetValue(month, out var count) ? count : 0
+            }).ToList();
+            response.OutboundData = outboundData;
+            #endregion
+            #region 鍏ュ簱
+            var inttboundCounts = db.Queryable<WCSTask>()
+           .Where(a => a.S_TYPE.Contains("鍏ュ簱") && a.N_B_STATE == 3 && a.T_END_TIME != null && a.T_END_TIME.Value.Year == year)
+           .ToList() // 鍔犺浇鍒板唴瀛�+           .GroupBy(a => a.T_END_TIME.Value.ToString("MM")) // 鎸夋湀浠藉垎缁�+           .ToDictionary(g => g.Key, g => g.Count()); // 杞负瀛楀吀锛堟湀浠�璁板綍鏁帮級
+            var intboundData = allMonths.Select(month => new BarChartData
+            {
+                Month = int.Parse(month),
+                Count = inttboundCounts.TryGetValue(month, out var count) ? count : 0
+            }).ToList();
+            response.InboundData = intboundData;
+            #endregion
+            #region 鏈畬鎴愬崟鎹噺
+            var Inttbounddjcount = db.Queryable<TN_Inbound_Order>().Where(s=>s.N_B_STATE==0).Count();
+            var Outtbounddjcount = db.Queryable<TN_Ll_Order>().Where(s=>s.N_B_STATE==0).Count();
+            var today = DateTime.Today;
+            var tomorrow = today.AddDays(1);
+
+            var IntodayCount = db.Queryable<WCSTask>()
+                .Where(s => s.N_B_STATE == 3 && s.S_TYPE.Contains("鍏ュ簱")&&
+                            s.T_END_TIME >= today &&
+                            s.T_END_TIME < tomorrow).Count();
+            var OuttodayCount = db.Queryable<WCSTask>()
+            .Where(s => s.N_B_STATE == 3 && s.S_TYPE.Contains("鍑哄簱") &&
+                        s.T_END_TIME >= today &&
+                        s.T_END_TIME < tomorrow).Count();
+            response.Inttbounddjcount = Inttbounddjcount;
+            response.Outtbounddjcount = Outtbounddjcount;
+            response.OuttodayCount = OuttodayCount;
+            response.IntodayCount = IntodayCount;
+            #endregion
+            #region 浠诲姟鍒楄〃
+            var tasklist = db.Queryable<WCSTask>().Where(s => s.N_B_STATE != 2).Select(s => new { s.S_CNTR_CODE, s.S_START_AREA, s.S_END_AREA, s.S_B_STATE }).Take(5).ToList() ;
+            var tasksList = tasklist.Select(t => new Tasks
+            {
+                S_CNTR_CODE = t.S_CNTR_CODE,
+                S_START_AREA = t.S_START_AREA,
+                S_END_AREA = t.S_END_AREA,
+                S_B_STATE = t.S_B_STATE
+            }).ToList();
+            response.ListTask = tasksList;
+            #endregion
+
+
+            #region 浠撳簱搴撳唴瀹℃牳
+            var ManCount = db.Queryable<CntrItemRel>()
+                           .Where(s => s.S_CNTR_TYPE == "婊℃墭")
+                           .GroupBy(s => s.S_CNTR_CODE)
+                           .Select(s => new { s.S_CNTR_CODE })
+                           .Count();
+            var ManName = "婊℃墭鐩�;
+
+            var BanCount = db.Queryable<CntrItemRel>()
+                           .Where(s => s.S_CNTR_TYPE == "鍗婃墭")
+                           .GroupBy(s => s.S_CNTR_CODE)
+                           .Select(s => new { s.S_CNTR_CODE })
+                           .Count();
+            var BanName = "鍗婃墭鐩�;
+            //鎵�湁瀹瑰櫒鐨勬暟閲�+            int allCntrcout = db.Queryable<LocCntrRel>().Count();
+            //鎵�湁瀹瑰櫒鐗╂枡鏁伴噺
+            int alltprcout = db.Queryable<CntrItemRel>()
+                     .GroupBy(s => s.S_CNTR_CODE)
+                     .Select(s => new { s.S_CNTR_CODE })
+                     .Count();
+
+            var KTCount = allCntrcout - alltprcout;
+            var KTName = "绌烘墭鐩�;
+
+            int alllocationcout = db.Queryable<Location>().Count();
+            var KHWCount = alllocationcout - allCntrcout;
+            var KHWName = "绌鸿揣浣�;
+
+            var list = new List<NB>
+        {
+            new NB { Name = ManName, Count = ManCount },
+            new NB { Name = BanName, Count = BanCount },
+            new NB { Name = KTName, Count = KTCount },
+            new NB { Name = KHWName, Count = KHWCount }
+        };
+            response.CKNData = list;
+            #endregion
+            return response;
+        
+        }
+
+            
+        #endregion
+
         /// <summary>
         /// 渚涘簲鍟嗘帴鏀舵帴鍙h幏鍙�         /// </summary>
@@ -326,7 +471,7 @@
             {
                 OtherReturnRoot.ITEM wcReturnRoot = new OtherReturnRoot.ITEM();
                 wcReturnRoot.WLPZBH = item.WLPZBH;
-                wcReturnRoot.WLPZND = item.WLPZND;
+                wcReturnRoot.ND = item.WLPZND;
                 wcReturnRoot.MSGCODE = item.resultCode;
                 wcReturnRoot.MSGDESP = item.resultMsg;
                 wcReturnRoots.Add(wcReturnRoot);

--
Gitblit v1.9.1