From bfec4da315abe8013a1683325bcf434c492dba0f Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 12 十月 2022 18:51:17 +0800
Subject: [PATCH] 问题处理

---
 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormBillController.cs |   61 +++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
index 8f3a078..d2d7dee 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
@@ -73,7 +73,7 @@
             {
                 if (num == 1)
                 {
-                    ds = oCN.RunProcReturn($"select isnull(DATEDIFF(DAY,GETDATE(),CONVERT(varchar(10),max(HMasterDate),20)),0) DayNum from  Sc_WorkBillSortBillSub where HInterID in ({sWhere}) and  HMasterDate>=CONVERT(varchar(10),GETDATE(),20) and HLockedSub=1", "Sc_WorkBillSortBillSub");
+                    ds = oCN.RunProcReturn($"select isnull(DATEDIFF(DAY,GETDATE(),CONVERT(varchar(10),max(HMasterDate),20))+1,0) DayNum from  Sc_WorkBillSortBillSub where HInterID in ({sWhere}) and  HMasterDate>=CONVERT(varchar(10),GETDATE(),20) and HLockedSub=1", "Sc_WorkBillSortBillSub");
                 }
                 else if (num == 2)
                 {
@@ -189,7 +189,7 @@
                         var HMainSourceEntryID = list[i]["婧愬崟瀛愬唴鐮�"].ToString();
                         var HPlanQty = list[i]["璁″垝鏁伴噺"].ToString();
 
-                        if (HSourceID == "")
+                        if (HSourceID == ""|| HSourceID == "0")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -198,7 +198,7 @@
                             return objJsonResult;
                         }
 
-                        ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceEntryID={HMainSourceEntryID}" +
+                        ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
                             $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
                         if (ds.Tables[0].Rows.Count > 0)
                         {
@@ -228,6 +228,37 @@
                             $" 0, {(HSplitQty == "" ? 0.ToString() : HSplitQty)}, {(HDayPlanSumQty == "" ? 0.ToString() : HDayPlanSumQty)},'{HPlanBeginDate}'," +
                             $"'{HSeOrderBillNo}','{HICMOBillType}',{(HSourceStockInQty == "" ? 0.ToString() : HSourceStockInQty)},{(HLeftPlanQty == "" ? 0.ToString() : HLeftPlanQty)},'{HOrderLev}',getdate()," +
                             $"{HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HPlanQty})");
+                    }
+                    else
+                    {
+                        var HMainSourceInterID = list[i]["婧愬崟涓诲唴鐮�"].ToString();
+                        var HMainSourceEntryID = list[i]["婧愬崟瀛愬唴鐮�"].ToString();
+                        var HICMOBillNo = list[i]["鐢熶骇璁㈠崟鍙�"].ToString();
+                        var HICMOEntrySEQ = list[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
+                        var HSourceID = list[i]["HSourceID"].ToString();
+
+                        if (HSourceID == "" || HSourceID == "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愪笉鑳戒负绌�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+                              $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
+
+                        if (ds.Tables[0].Rows.Count > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)} where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
                     }
 
                     oCN.RunProc($"update Sc_WorkBillSortBillMain set HDayPlanSumQty={list[i]["鏃ヨ鍒掓暟閲忔�婚噺"].ToString()} where HInterID={(HInterID==0?int.Parse(list[i]["hmainid"].ToString()):HInterID)} and HBillNo='{(HBillNo==""?list[i]["鍗曟嵁鍙�"].ToString(): HBillNo)}'");
@@ -1098,15 +1129,17 @@
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 閿佸畾
         [Route("JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHLockedDay")]
         [HttpGet]
-        public object JIT_DayPlanPlatFormBillHLockedDay(string sWhere, int HLockedDay)
+        public object JIT_DayPlanPlatFormBillHLockedDay(int HLockedDay,int HWorkShopID)
         {
             try
             {
-                if (sWhere != null && sWhere != "")
-                {
-                    oCN.RunProc("update Sc_WorkBillSortBillSub set HLockedSub=1" +
-                    $" where HInterID in ({sWhere}) and HMasterDate between  DATEADD(day, -1, getdate()) and DATEADD(day,{(HLockedDay - 1)},getdate()) ");
-                }
+                oCN.RunProc("update b set HLockedSub=0 from Sc_WorkBillSortBillMain a join Sc_WorkBillSortBillSub b on a.HInterID = b.HInterID " +
+              $" where a.HWorkShopID={HWorkShopID}");
+
+                oCN.RunProc("update b set HLockedSub=1 from Sc_WorkBillSortBillMain a join Sc_WorkBillSortBillSub b on a.HInterID = b.HInterID " +
+                $" where  HMasterDate between  DATEADD(day, -1, getdate()) " +
+                $"and DATEADD(day,{(HLockedDay - 1)},getdate())  and a.HWorkShopID={HWorkShopID}");
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";
@@ -1127,15 +1160,13 @@
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 瑙i攣
         [Route("JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHUnlockDay")]
         [HttpGet]
-        public object JIT_DayPlanPlatFormBillHUnlockDay(string sWhere, int HLockedDay)
+        public object JIT_DayPlanPlatFormBillHUnlockDay(int HWorkShopID)
         {
             try
             {
-                if (sWhere != null && sWhere != "")
-                {
-                    oCN.RunProc("update Sc_WorkBillSortBillSub set HLockedSub=0" +
-                    $" where HInterID in ({sWhere}) and HMasterDate between  DATEADD(day, -1, getdate()) and DATEADD(day,{(HLockedDay - 1)},getdate()) ");
-                }
+                oCN.RunProc("update b set HLockedSub=0 from Sc_WorkBillSortBillMain a join Sc_WorkBillSortBillSub b on a.HInterID = b.HInterID " +
+              $" where a.HWorkShopID={HWorkShopID}");
+
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "Sucess锛�";

--
Gitblit v1.9.1