yangle
2022-10-12 bfec4da315abe8013a1683325bcf434c492dba0f
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/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 ç”Ÿäº§æ—¥è®¡åˆ’平台 è§£é”
        [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!";