From 146fa02f2ff92f9687fc9e099e2e812f785e04b1 Mon Sep 17 00:00:00 2001
From: zzr99 <1940172413@qq.com>
Date: 星期一, 25 四月 2022 13:32:32 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 /dev/null                                                            |  181 ----------------
 WebAPI/Controllers/SCGL/日计划管理/Sc_JIT_ComplementGoodBillController.cs |    0 
 WebAPI/Models/Cg_PODemandPlanBillMain.cs                             |   19 +
 WebAPI/Controllers/SCGL/日计划管理/Sc_WorkBillSortBillController.cs       |   44 +++
 WebAPI/Models/Cg_PODemandPlanBillSub.cs                              |   48 ++++
 WebAPI/WebAPI.csproj                                                 |    8 
 WebAPI/Controllers/SCGL/日计划管理/Cg_PODemandPlanBillController.cs       |  327 +++++++++++++++++++++++++++++
 7 files changed, 434 insertions(+), 193 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Cg_PODemandPlanBillController.cs b/WebAPI/Controllers/SCGL/Cg_PODemandPlanBillController.cs
deleted file mode 100644
index 4f7d441..0000000
--- a/WebAPI/Controllers/SCGL/Cg_PODemandPlanBillController.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-锘縰sing Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Web;
-using System.Web.Http;
-using WebAPI.Models;
-
-namespace WebAPI.Controllers.SCGL
-{
-    public class Cg_PODemandPlanBillController : ApiController
-    {
-        private json objJsonResult = new json();
-        public DataSet ds = new DataSet();
-        public WebServer webserver = new WebServer();
-        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-
-        #region 鎻愭枡璁″垝鍗� 鍒楄〃
-        [Route("Cg_PODemandPlanBill/Cg_PODemandPlanBillList")]
-        [HttpGet]
-        public object Cg_PODemandPlanBillList(string sWhere, string user)
-        {
-            try
-            {
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Query", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                ds = oCN.RunProcReturn("select * from  h_v_JIT_Cg_PODemandPlanBillList where 1=1" + sWhere+ "order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanBillList");
-
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = ds.Tables[0];
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
-        #region 鎻愭枡璁″垝鍗� 鍒犻櫎
-        [Route("Cg_PODemandPlanBill/DelPODemandPlanBillList")]
-        [HttpGet]
-        public object DelPODemandPlanBillList(string HInterID, string HEntryID, string User)
-        {
-            try
-            {
-                //鍒犻櫎鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Drop", 1, false, User))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愬垹闄わ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList");
-
-                if (ds.Tables[0].Rows.Count > 0)
-                {
-                    if (ds.Tables[0].Rows[0]["鍗曟嵁鐘舵��"].ToString() != "1")
-                    {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 0;
-                        objJsonResult.Message = "褰撳墠鍗曟嵁涓嶈兘鍒犻櫎锛�";
-                        objJsonResult.data = null;
-                        return objJsonResult;
-                    }
-
-                    oCN.BeginTran();//寮�鍚簨鍔�
-
-                    if (ds.Tables[0].Rows.Count == 1)
-                    {
-                        oCN.RunProc($"delete from Cg_PODemandPlanBillMain where HInterID={HInterID}");
-                    }
-                    oCN.RunProc($"delete from Cg_PODemandPlanBillSub where HInterID={HInterID} and HEntryID={HEntryID}");
-
-                    oCN.Commit();//缁撴潫浜嬪姟
-
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍒犻櫎锛�";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                oCN.RollBack();//鍥炴粴浜嬪姟
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
-        #region 鎻愭枡璁″垝鍗� 鍏抽棴
-        [Route("Cg_PODemandPlanBill/ClosePODemandPlanBillList")]
-        [HttpGet]
-        public object ClosePODemandPlanBillList(string HInterID, string User)
-        {
-            try
-            {
-                //鍏抽棴鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Close", 1, false, User))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳潈闄愬叧闂紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList");
-
-                if (ds.Tables[0].Rows.Count > 0)
-                {
-                    if (ds.Tables[0].Rows[0]["鍗曟嵁鐘舵��"].ToString() == "2")
-                    {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 0;
-                        objJsonResult.Message = "褰撳墠鍗曟嵁姝e湪瀹℃牳,涓嶈兘鍏抽棴锛�";
-                        objJsonResult.data = null;
-                        return objJsonResult;
-                    }
-
-                    oCN.BeginTran();//寮�鍚簨鍔�
-
-                    oCN.RunProc($"update Cg_PODemandPlanBillMain set HBillStatus=3,HCloseMan='{User}',HCloseDate=getdate()   where HInterID={HInterID}");
-
-                    oCN.Commit();//缁撴潫浜嬪姟
-
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鍏抽棴鎴愬姛锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍏抽棴锛�";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                oCN.RollBack();//鍥炴粴浜嬪姟
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-    }
-}
\ No newline at end of file
diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Cg_PODemandPlanBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Cg_PODemandPlanBillController.cs"
new file mode 100644
index 0000000..7cbefd5
--- /dev/null
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Cg_PODemandPlanBillController.cs"
@@ -0,0 +1,327 @@
+锘縰sing Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+using System.Web.Http;
+using WebAPI.Models;
+
+namespace WebAPI.Controllers.SCGL
+{
+    public class Cg_PODemandPlanBillController : ApiController
+    {
+        private json objJsonResult = new json();
+        public DataSet ds = new DataSet();
+        public WebServer webserver = new WebServer();
+        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        Cg_PODemandPlanBillMain omdelMian = new Cg_PODemandPlanBillMain();
+        List<Cg_PODemandPlanBillSub> omodelsub = new List<Cg_PODemandPlanBillSub>();
+
+        #region 鎻愭枡璁″垝鍗� 鍒楄〃
+        [Route("Cg_PODemandPlanBill/Cg_PODemandPlanBillList")]
+        [HttpGet]
+        public object Cg_PODemandPlanBillList(string sWhere, string user)
+        {
+            try
+            {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from  h_v_JIT_Cg_PODemandPlanBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanBillList");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎻愭枡璁″垝鍗�  娣诲姞/淇敼
+        [Route("Cg_PODemandPlanBill/AddPODemandPlanBillList")]
+        [HttpPost]
+        public object AddPODemandPlanBillList([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain(msg1);
+            if (objJsonResult.code == "0")
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = objJsonResult.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+            int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d
+            int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+            string user = sArray[4].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Cg_PODemandPlanBillMain>(msg2);
+                string BillType = "4608";
+
+
+                if (OperationType == 1)//鏂板
+                {
+                    //涓昏〃
+                    oCN.RunProc("insert into Cg_PODemandPlanBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType" +
+                                 ",HBillSubType,HDate,HBillStatus,HMaker,HMakeDate" +
+                                 ",HSubORGID ,HAddress,HPURCHASEORGID,HSupplierID ,HSettleCurrId" +
+                                 ",HRemark,HExplanation)" +
+                                $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}', {DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}'" +
+                                $", '{BillType}','{omdelMian.HDate}',1, '{omdelMian.HMaker}',GETDATE()," +
+                                $"{omdelMian.HSubORGID},'{omdelMian.HAddress}',{omdelMian.HPURCHASEORGID}, {omdelMian.HSupplierID}, {omdelMian.HSettleCurrId}" +
+                                $",'{omdelMian.HRemark}','{omdelMian.HExplanation}')");
+                }
+                else if (OperationType == 3)
+                {
+                    //淇敼
+                    oCN.RunProc($"update  Cg_PODemandPlanBillMain set HUpDater='{omdelMian.HMaker}',HUpDateDate=GETDATE()" +
+                                $",HSubORGID={omdelMian.HSubORGID},HAddress='{omdelMian.HAddress}',HPURCHASEORGID={omdelMian.HPURCHASEORGID}" +
+                                $",HSupplierID={omdelMian.HSupplierID},HSettleCurrId={omdelMian.HSettleCurrId}" +
+                                $",HRemark='{omdelMian.HRemark}',HExplanation='{omdelMian.HExplanation}' where HInterID={omdelMian.HInterID}");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub(msg3, hentryid);
+                if (objJsonResult.code == "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string msg3, int hentryid)
+        {
+            if (hentryid != -1)
+            {
+                //鑾峰彇琛ㄦ牸鏁版嵁
+                ds = oCN.RunProcReturn($"select * from  h_v_JIT_Cg_PODemandPlanBillList where 鍗曟嵁鍙�='{omdelMian.HBillNo}'", "h_v_JIT_Cg_PODemandPlanBillList");
+                //鍒犻櫎瀛愯〃
+                oCN.RunProc("delete from Cg_PODemandPlanBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
+            }
+
+
+            omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanBillSub>>(msg3);
+            int i = 1;
+            //鎻掑叆瀛愯〃
+            foreach (Models.Cg_PODemandPlanBillSub oSub in omodelsub)
+            {
+                oCN.RunProc("insert into Cg_PODemandPlanBillSub(HInterID,HEntryID,HLaterReason,HMaterID,HMaterName" +
+                            ", HMaterModel, HUnitID, HErpClsID, HQty, HRemark" +
+                            ", HPURCHASEORGID, HStatus, HFixleadTime, HDayPlanBillNo, HSourceInterID" +
+                            ", HSourceEntryID, HSourceBillNo, HSourceBillType, HWorkShopID, HDayPlanDate" +
+                            ", HRelationQty1, HPOOrderInterID, HPOOrderEntryID, HPOOrderBillNo, HPOOrderBillSEQ" +
+                            ", HWWOrderInterID, HWWOrderEntryID, HWWOrderBillNo, HPurchaseDeptID, HCloseTypeSub" +
+                            ", HCloseMan, HEntryCloseDate, HSendQty, HReciveQty, HCloseStatus" +
+                            ", HRemoveQty, HSeOrderBillNo, HUnReciveQty, HPOOrderBillDate, HPOOrderBillDeliveryDate" +
+                            ", HPOOrderBillRemark, HPOOrderBillNote)" +
+                            $"values({omdelMian.HInterID}, {(hentryid == -1 ? i : omodelsub.Count == 1 ? hentryid : i == 1 ? hentryid : (i + ds.Tables[0].Rows.Count - 1))}, '{oSub.HLaterReason}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}, '{oSub.HMaterName}'" +
+                            $", '{oSub.HMaterModel}', {(oSub.HUnitID == null ? 0 : oSub.HUnitID)}, '{oSub.HErpClsID}', {(oSub.HQty == null ? 0 : oSub.HQty)}, '{oSub.HRemark}'" +
+                            $", {(oSub.HPURCHASEORGID == null ? 0 : oSub.HPURCHASEORGID)}, '{oSub.HStatus}', {(oSub.HFixleadTime == null ? 0 : oSub.HFixleadTime)}, '{oSub.HDayPlanBillNo}', {oSub.HSourceInterID}" +
+                            $", {oSub.HSourceEntryID}, '{oSub.HSourceBillNo}', '{oSub.HSourceBillType}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HDayPlanDate}'" +
+                            $", {(oSub.HRelationQty1 == null ? 0 : oSub.HRelationQty1)}, {(oSub.HPOOrderInterID == null ? 0 : oSub.HPOOrderInterID)},{(oSub.HPOOrderEntryID == null ? 0 : oSub.HPOOrderEntryID)}, '{oSub.HPOOrderBillNo}',{(oSub.HPOOrderBillSEQ == null ? 0 : oSub.HPOOrderBillSEQ)}" +
+                            $",{(oSub.HWWOrderInterID == null ? 0 : oSub.HWWOrderInterID)},{(oSub.HWWOrderEntryID == null ? 0 : oSub.HWWOrderEntryID)}, '{oSub.HWWOrderBillNo}',{(oSub.HPurchaseDeptID == null ? 0 : oSub.HPurchaseDeptID)}, '{(oSub.HCloseTypeSub == true ? 1 : 0)}'" +
+                            $", '{oSub.HCloseMan}','{oSub.HEntryCloseDate}',{(oSub.HSendQty == null ? 0 : oSub.HSendQty)},{(oSub.HReciveQty == null ? 0 : oSub.HReciveQty)}, '{(oSub.HCloseStatus == true ? 1 : 0)}'" +
+                            $",{(oSub.HRemoveQty == null ? 0 : oSub.HRemoveQty)}, '{oSub.HSeOrderBillNo}',{(oSub.HUnReciveQty == null ? 0 : oSub.HUnReciveQty)}, '{oSub.HPOOrderBillDate}', '{oSub.HPOOrderBillDeliveryDate}'" +
+                            $", '{oSub.HPOOrderBillRemark}', '{oSub.HPOOrderBillNote}')");
+                i++;
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        #endregion
+
+        #region 鎻愭枡璁″垝鍗� 鍒犻櫎
+        [Route("Cg_PODemandPlanBill/DelPODemandPlanBillList")]
+        [HttpGet]
+        public object DelPODemandPlanBillList(string HInterID, string HEntryID, string User)
+        {
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Drop", 1, false, User))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (ds.Tables[0].Rows[0]["鍗曟嵁鐘舵��"].ToString() != "1")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "褰撳墠鍗曟嵁涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();//寮�鍚簨鍔�
+
+                    if (ds.Tables[0].Rows.Count == 1)
+                    {
+                        oCN.RunProc($"delete from Cg_PODemandPlanBillMain where HInterID={HInterID}");
+                    }
+                    oCN.RunProc($"delete from Cg_PODemandPlanBillSub where HInterID={HInterID} and HEntryID={HEntryID}");
+
+                    oCN.Commit();//缁撴潫浜嬪姟
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍒犻櫎锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();//鍥炴粴浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎻愭枡璁″垝鍗� 鍏抽棴
+        [Route("Cg_PODemandPlanBill/ClosePODemandPlanBillList")]
+        [HttpGet]
+        public object ClosePODemandPlanBillList(string HInterID, string User)
+        {
+            try
+            {
+                //鍏抽棴鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Close", 1, false, User))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (ds.Tables[0].Rows[0]["鍗曟嵁鐘舵��"].ToString() == "2")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "褰撳墠鍗曟嵁姝e湪瀹℃牳,涓嶈兘鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();//寮�鍚簨鍔�
+
+                    oCN.RunProc($"update Cg_PODemandPlanBillMain set HBillStatus=3,HCloseMan='{User}',HCloseDate=getdate()   where HInterID={HInterID}");
+
+                    oCN.Commit();//缁撴潫浜嬪姟
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍏抽棴鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "褰撳墠鍗曟嵁涓嶅瓨鍦�,鏃犳硶鍏抽棴锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();//鍥炴粴浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+    }
+}
diff --git a/WebAPI/Controllers/SCGL/Sc_JIT_ComplementGoodBillController.cs "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs"
similarity index 100%
rename from WebAPI/Controllers/SCGL/Sc_JIT_ComplementGoodBillController.cs
rename to "WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs"
diff --git a/WebAPI/Controllers/SCGL/Sc_WorkBillSortBillController.cs "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkBillSortBillController.cs"
similarity index 76%
rename from WebAPI/Controllers/SCGL/Sc_WorkBillSortBillController.cs
rename to "WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkBillSortBillController.cs"
index c04e494..fbf08e6 100644
--- a/WebAPI/Controllers/SCGL/Sc_WorkBillSortBillController.cs
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_WorkBillSortBillController.cs"
@@ -138,14 +138,34 @@
                 else if (OperationType == 3)
                 {
                     //淇敼
-                    oCN.RunProc("UpDate Gy_WorkWarehouseBillMain set  " +
-                " HOrgId='" + omdelMian.HPRDORGID + "'" +
-                ",HUpDater='" + omdelMian.HMaker + "'" +
-                ",HUpDateDate='" + DateTime.Now + "'" +
-                " where HInterID=" + omdelMian.HInterID.ToString());
-
-                    //鍒犻櫎瀛愯〃
-                    oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
+                    oCN.RunProc($"update Sc_WorkBillSortBillMain set HUpDater='{omdelMian.HMaker}',HUpDateDate=GETDATE()" +
+                                  $", HRemark='{omdelMian.HRemark}', HPrintQty={(omdelMian.HPrintQty == null ? 0 : omdelMian.HPrintQty)}" +
+                                  $", HDeptID={omdelMian.HDeptID}, HSeOrderBillNo='{omdelMian.HSeOrderBillNo}', HSourceQty= {(omdelMian.HSourceQty == null ? 0 : omdelMian.HSourceQty)}" +
+                                  $", HInStockQty={(omdelMian.HInStockQty == null ? 0 : omdelMian.HInStockQty)}, HMaterID={omdelMian.HMaterID}" +
+                                  $", HMaterName= '{omdelMian.HMaterName}', HMaterModel= '{omdelMian.HMaterModel}', HGroupID={omdelMian.HGroupID}" +
+                                  $", HWorkShopID={omdelMian.HWorkShopID}, HRelationQty={(omdelMian.HRelationQty == null ? 0 : omdelMian.HRelationQty)}" +
+                                  $", HUnitID={omdelMian.HUnitID}, HWorkerID={omdelMian.HWorkerID}, HSourceID={omdelMian.HSourceID}" +
+                                  $", HBeginWorkTimes={(omdelMian.HBeginWorkTimes == null ? 0 : omdelMian.HBeginWorkTimes)}, HInStockOwnerTypeID= '{omdelMian.HInStockOwnerTypeID}'" +
+                                  $", HSplitRelationQty={(omdelMian.HSplitRelationQty == null ? 0 : omdelMian.HSplitRelationQty)}, HOrderLev='{omdelMian.HOrderLev}'" +
+                                  $", HWorkQty={(omdelMian.HWorkQty == null ? 0 : omdelMian.HWorkQty)}" +
+                                  $", HSplitPlanQty={(omdelMian.HSplitPlanQty == null ? 0 : omdelMian.HSplitPlanQty)}, HOwnerTypeID='{omdelMian.HOwnerTypeID}'" +
+                                  $", HPlanBeginDate= '{omdelMian.HPlanBeginDate}', HPlanEndDate='{omdelMian.HPlanEndDate}', HICMOBillNo='{omdelMian.HICMOBillNo}'" +
+                                  $", HOwnerID={omdelMian.HOwnerID}, HBatchNo='{omdelMian.HBatchNo}', HYX={(omdelMian.HYX == null ? 0 : omdelMian.HYX)}" +
+                                  $", HProdTimes={(omdelMian.HProdTimes == null ? 0 : omdelMian.HProdTimes)}, HEntrustORGID={omdelMian.HEntrustORGID}" +
+                                  $", HPlanQty={(omdelMian.HPlanQty == null ? 0 : omdelMian.HPlanQty)}, HPreparatDate='{omdelMian.HPreparatDate}'" +
+                                  $", HOrderNeedQty={(omdelMian.HOrderNeedQty == null ? 0 : omdelMian.HOrderNeedQty)}, HOrderCommitDate='{omdelMian.HOrderCommitDate}'" +
+                                  $", HCompleteQty={(omdelMian.HCompleteQty == null ? 0 : omdelMian.HCompleteQty)}" +
+                                  $", HSeOrderBillQty={(omdelMian.HSeOrderBillQty == null ? 0 : omdelMian.HSeOrderBillQty)}, HICMOInterID={(omdelMian.HICMOInterID == null ? 0 : omdelMian.HICMOInterID)}" +
+                                  $", HKTQ={(omdelMian.HKTQ == null ? 0 : omdelMian.HKTQ)}, HStockInORGID={(omdelMian.HStockInORGID == null ? 0 : omdelMian.HStockInORGID)}" +
+                                  $", HDayPlanSumQty={(omdelMian.HDayPlanSumQty == null ? 0 : omdelMian.HDayPlanSumQty)}" +
+                                  $", HSourceBillNo='{omdelMian.HSourceBillNo}', HICMOEntryID={(omdelMian.HICMOEntryID == null ? 0 : omdelMian.HICMOEntryID)}" +
+                                  $", HMainInterID={(omdelMian.HMainInterID == null ? 0 : omdelMian.HMainInterID)}, HProdORGID={omdelMian.HProdORGID}" +
+                                  $", HLeftPlanQty={(omdelMian.HLeftPlanQty == null ? 0 : omdelMian.HLeftPlanQty)}" +
+                                  $", HEmpID={(omdelMian.HEmpID == null ? 0 : omdelMian.HEmpID)}, HInStockOwnerID={omdelMian.HInStockOwnerID}, HICMOEntrySEQ={(omdelMian.HICMOEntrySEQ == null ? 0 : omdelMian.HICMOEntrySEQ)}" +
+                                  $", HICMOBillType='{omdelMian.HICMOBillType}', HCloseCount={(omdelMian.HCloseCount == null ? 0 : omdelMian.HCloseCount)}" +
+                                  $", HOrderType= '{omdelMian.HOrderType}', HSplitQty={(omdelMian.HSplitQty == null ? 0 : omdelMian.HSplitQty)}, HSourceStockInQty={(omdelMian.HSourceStockInQty == null ? 0 : omdelMian.HSourceStockInQty)}" +
+                                  $", HPriority={(omdelMian.HPriority == null ? 0 : omdelMian.HPriority)}, HLocked='{(omdelMian.HLocked == true ? 1 : 0)}'" +
+                                  $", HHangUp='{(omdelMian.HHangUp == true ? 1 : 0)}' where HInterID={omdelMian.HInterID}");
                 }
                 //淇濆瓨瀛愯〃
                 objJsonResult = AddBillSub(msg3, hentryid);
@@ -176,6 +196,12 @@
 
         public json AddBillSub(string msg3, int hentryid)
         {
+            //鑾峰彇琛ㄦ牸鏁版嵁
+            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{omdelMian.HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList");
+
+            //鍒犻櫎瀛愯〃
+            oCN.RunProc("delete from Sc_WorkBillSortBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
+
             omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Sc_WorkBillSortBillSub>>(msg3);
             int i = 1;
             //鎻掑叆瀛愯〃
@@ -185,7 +211,7 @@
                             ", HRptFinishQty, HTimes, HUseTimes, HBTimes, HETimes" +
                             ", HDateSub, HCloseMan, HEntryCloseDate, HCloseTypeSub, HColumn" +
                             ", HLockedSub, HComplete, HStatusTag, HIsHandModify)" +
-                            $"values({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid)}, '{oSub.HRemark}', '{oSub.HMasterDate}', {(oSub.HQty == null ? 0: oSub.HQty)}" +
+                            $"values({omdelMian.HInterID}, {(hentryid == -1 ? i : omodelsub.Count==1? hentryid:i==1? hentryid:(i+ds.Tables[0].Rows.Count-1))}, '{oSub.HRemark}', '{oSub.HMasterDate}', {(oSub.HQty == null ? 0: oSub.HQty)}" +
                             $", {(oSub.HRptFinishQty == null ? 0: oSub.HRptFinishQty)}, {(oSub.HTimes == null ? 0: oSub.HTimes)}, {(oSub.HUseTimes == null ? 0: oSub.HUseTimes)}, '{oSub.HBTimes}', '{oSub.HETimes}'" +
                             $", '{oSub.HDateSub}', '{oSub.HCloseMan}', '{oSub.HEntryCloseDate}', {(oSub.HCloseTypeSub == true ? 1 : 0)}, '{oSub.HColumn}'" +
                             $", '{(oSub.HLockedSub == true ? 1 : 0)}', '{oSub.HComplete}', '{(oSub.HStatusTag == true ? 1 : 0)}', '{(oSub.HIsHandModify == true ? 1 : 0)}')");
diff --git a/WebAPI/Models/Cg_PODemandPlanBillMain.cs b/WebAPI/Models/Cg_PODemandPlanBillMain.cs
new file mode 100644
index 0000000..8b4dc1a
--- /dev/null
+++ b/WebAPI/Models/Cg_PODemandPlanBillMain.cs
@@ -0,0 +1,19 @@
+锘縰sing DBUtility;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+    public class Cg_PODemandPlanBillMain: ClsXt_BaseBillMain
+    {
+        public string HDocumentStatus { get; set; }
+        public string HAddress { get; set; }
+        public string HExplanation { get; set; }
+        public int HSubORGID;
+        public int HSupplierID;
+        public int HPURCHASEORGID;
+        public int HSettleCurrId;
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/Models/Cg_PODemandPlanBillSub.cs b/WebAPI/Models/Cg_PODemandPlanBillSub.cs
new file mode 100644
index 0000000..f57d183
--- /dev/null
+++ b/WebAPI/Models/Cg_PODemandPlanBillSub.cs
@@ -0,0 +1,48 @@
+锘縰sing DBUtility;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+    public class Cg_PODemandPlanBillSub : ClsXt_BaseBillSub
+    {
+        public double? HRelationQty1;
+        public double? HQty;
+        public double? HSendQty;
+        public double? HReciveQty;
+        public double? HRemoveQty;
+        public double? HUnReciveQty;
+        public int? HPOOrderInterID;
+        public int? HPOOrderEntryID;
+        public int? HWWOrderInterID;
+        public int? HWWOrderEntryID;
+        public int? HPURCHASEORGID;
+        public int? HStockInOrgID;
+        public int? HInStocKOwnerID;
+        public int? HUnitID;
+        public int? HMaterID;
+        public int? HFixleadTime;
+        public int? HPOOrderBillSEQ;
+        public int? HOrderEmpID;
+        public int? HWorkShopID;
+        public int? HPurchaseDeptID;
+        public string HPOOrderBillNo { get; set; }
+        public string HWWOrderBillNo { get; set; }
+        public string HMaterName { get; set; }
+        public string HMaterModel { get; set; }
+        public string HStatus { get; set; }
+        public string HLaterReason { get; set; }
+        public string HErpClsID { get; set; }
+        public string HPOOrderBillRemark { get; set; }
+        public string HPOOrderBillNote { get; set; }
+        public string HSeOrderBillNo { get; set; }
+        public string HDayPlanBillNo { get; set; }
+        public DateTime? HDayPlanDate= DateTime.Parse("1900-01-01 00:00:00");
+        public DateTime? HPOOrderBillDate= DateTime.Parse("1900-01-01 00:00:00");
+        public DateTime? HPOOrderBillDeliveryDate= DateTime.Parse("1900-01-01 00:00:00");
+        public bool HCloseStatus;
+        public bool HCloseTypeSub;
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index fbd7ae6..4818f42 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -359,14 +359,14 @@
     <Compile Include="Controllers\CJGL\Cj_StationInBillController.cs" />
     <Compile Include="Controllers\CJGL\Cj_StationEntrustOutBillController.cs" />
     <Compile Include="Controllers\CJGL\Sc_WorkBillAutoSortBillMainController.cs" />
-    <Compile Include="Controllers\SCGL\Cg_PODemandPlanBillController.cs" />
+    <Compile Include="Controllers\SCGL\鏃ヨ鍒掔鐞哱Cg_PODemandPlanBillController.cs" />
     <Compile Include="Controllers\SCGL\Sc_CallGoodsBackRequestBillController.cs" />
     <Compile Include="Controllers\SCGL\Sc_ComplementGoodBillController.cs" />
     <Compile Include="Controllers\SCGL\Sc_ComplementGoodsController.cs" />
     <Compile Include="Controllers\SCGL\Sc_ICBomBillController.cs" />
-    <Compile Include="Controllers\SCGL\Sc_JIT_ComplementGoodBillController.cs" />
+    <Compile Include="Controllers\SCGL\鏃ヨ鍒掔鐞哱Sc_JIT_ComplementGoodBillController.cs" />
     <Compile Include="Controllers\SCGL\鏃ヨ鍒掔鐞哱JIT_CompleteController..cs" />
-    <Compile Include="Controllers\SCGL\Sc_WorkBillSortBillController.cs" />
+    <Compile Include="Controllers\SCGL\鏃ヨ鍒掔鐞哱Sc_WorkBillSortBillController.cs" />
     <Compile Include="Controllers\Sc_PckSplitBillController.cs" />
     <Compile Include="Controllers\GZGL\Gy_DuSubsidyItemBillController.cs" />
     <Compile Include="Controllers\GZGL\Gy_WorkPayTypeBillController.cs" />
@@ -519,6 +519,8 @@
     <Compile Include="HttpClient.cs" />
     <Compile Include="InvokeHelper.cs" />
     <Compile Include="Log.cs" />
+    <Compile Include="Models\Cg_PODemandPlanBillMain.cs" />
+    <Compile Include="Models\Cg_PODemandPlanBillSub.cs" />
     <Compile Include="Models\Cg_PODemandPlanConfigBillSub.cs" />
     <Compile Include="Models\ClsGy_StockCheckItemBill.cs" />
     <Compile Include="Models\ClsQK_PackingBill.cs" />

--
Gitblit v1.9.1