ch
2022-05-24 22971886a0e1897aabf62b228215bbee3f2d5a6c
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/Sc_JIT_ComplementGoodBillController.cs
@@ -91,9 +91,8 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id
            int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改
            string user = sArray[4].ToString();
            int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("JIT_ComplementGoodBill_Edit", 1, false, user))
@@ -106,8 +105,23 @@
                }
                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
                if (omdelMian.HPRDORGID.ToString() == "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "组织不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string BillType = "4612";
                ds = ds = oCN.RunProcReturn($"select * from  h_v_JIT_Gy_WorkWarehouseBillList where hmainid={omdelMian.HInterID} and  å•据号='{omdelMian.HBillNo}'", "h_v_JIT_Gy_WorkWarehouseBillList");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    OperationType = 3;
                }
                if (OperationType == 1)//新增
                {
@@ -123,12 +137,9 @@
                ",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 + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3, hentryid);
                objJsonResult = AddBillSub(msg3);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
@@ -154,9 +165,33 @@
            }
        }
        public json AddBillSub(string msg3, int hentryid)
        public json AddBillSub(string msg3)
        {
            omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_WorkWarehouseBillMainSub>>(msg3);
            foreach (Models.Gy_WorkWarehouseBillMainSub oSub in omodelsub)
            {
                if (oSub.HWorkShopID == 0 || oSub.HWorkShopID ==null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "生产车间不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HWHID == 0|| oSub.HWHID == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "仓库不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            //删除子表
            oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
            int i = 1;
            //插入子表
            foreach (Models.Gy_WorkWarehouseBillMainSub oSub in omodelsub)
@@ -164,7 +199,7 @@
                oCN.RunProc("insert into Gy_WorkWarehouseBillMainSub(HInterID,HEntryID,HRemark,HWorkShopID," +
                    "HWorkShopName,HWHID,HWHName) " +
                   "values("
                   + omdelMian.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HRemark + "'," + (oSub.HWorkShopID==null?0:oSub.HWorkShopID)
                   + omdelMian.HInterID.ToString() + "," + i + ",'" + oSub.HRemark + "'," + (oSub.HWorkShopID==null?0:oSub.HWorkShopID)
                   + ",'" +oSub.HWorkShopName + "'," + (oSub.HWHID==null?0: oSub.HWHID) + ",'" + oSub.HWHName.ToString()+ "') ");
                i++;
            }
@@ -316,9 +351,8 @@
            string msg2 = sArray[0].ToString();//主表数据
            string msg3 = sArray[1].ToString();//子表数据
            int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id
            int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改
            string user = sArray[4].ToString();
            int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanConfigBill_Edit", 1, false, user))
@@ -333,6 +367,11 @@
                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
                string BillType = "4611";
                ds = ds = oCN.RunProcReturn($"select * from  h_v_JIT_Cg_PODemandPlanConfigBillList where hmainid={omdelMian.HInterID} and  å•据号='{omdelMian.HBillNo}'", "h_v_JIT_Cg_PODemandPlanConfigBillList");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    OperationType = 3;
                }
                if (OperationType == 1)//新增
                {
@@ -348,12 +387,9 @@
                ",HUpDater='" + omdelMian.HMaker + "'" +
                ",HUpDateDate='" + DateTime.Now + "'" +
                " where HInterID=" + omdelMian.HInterID.ToString());
                    //删除子表
                    oCN.RunProc("delete from Cg_PODemandPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
                }
                //保存子表
                objJsonResult = AddPODBillSub(msg3, hentryid);
                objJsonResult = AddPODBillSub(msg3);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
@@ -379,9 +415,58 @@
            }
        }
        public json AddPODBillSub(string msg3, int hentryid)
        public json AddPODBillSub(string msg3)
        {
            omodelPODsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanConfigBillSub>>(msg3);
            foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub)
            {
                if (oSub.HSupplierID == 0 || oSub.HSupplierID == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "供应商不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HMaterID == 0 || oSub.HMaterID == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "物料不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HLeadTime == 0 || oSub.HLeadTime == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT供货提前期不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT到货前置期不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT送货控制天数不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            //删除子表
            oCN.RunProc("delete from Cg_PODemandPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
            int i = 1;
            //插入子表
            foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub)
@@ -389,7 +474,7 @@
                oCN.RunProc("insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," +
                    "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
                    "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" +
                    $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HSupplierID==null?0: oSub.HSupplierID)}, '{oSub.HSupplierName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
                    $"({omdelMian.HInterID}, {i}, '{oSub.HRemark}', {(oSub.HSupplierID==null?0: oSub.HSupplierID)}, '{oSub.HSupplierName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
                    $" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," +
                    $" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) ");
                i++;
@@ -542,9 +627,8 @@
            string msg2 = sArray[0].ToString();//主表数据
            string msg3 = sArray[1].ToString();//子表数据
            int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id
            int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改
            string user = sArray[4].ToString();
            int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改
            string user = sArray[3].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("JIT_NeedMaterPlanConfigBill_Edit", 1, false, user))
@@ -558,6 +642,12 @@
                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
                string BillType = "4615";
                ds = ds = oCN.RunProcReturn($"select * from  h_v_JIT_NeedMaterPlanConfigBillList where hmainid={omdelMian.HInterID} and  å•据号='{omdelMian.HBillNo}'", "h_v_JIT_NeedMaterPlanConfigBillList");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    OperationType = 3;
                }
                if (OperationType == 1)//新增
@@ -575,12 +665,9 @@
                ",HUpDater='" + omdelMian.HMaker + "'" +
                ",HUpDateDate='" + DateTime.Now + "'" +
                " where HInterID=" + omdelMian.HInterID.ToString());
                    //删除子表
                    oCN.RunProc("delete from JIT_NeedMaterPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
                }
                //保存子表
                objJsonResult = AddNeedBillSub(msg3, hentryid);
                objJsonResult = AddNeedBillSub(msg3);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
@@ -606,9 +693,57 @@
            }
        }
        public json AddNeedBillSub(string msg3, int hentryid)
        public json AddNeedBillSub(string msg3)
        {
            omodelNeedsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JIT_NeedMaterPlanConfigBillSub>>(msg3);
            foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub)
            {
                if (oSub.HWorkShopID == 0 || oSub.HWorkShopID == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "生产车间不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HMaterID == 0 || oSub.HMaterID == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "物料不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HLeadTime == 0 || oSub.HLeadTime == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT供货提前期不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT到货前置期不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = " JIT送货控制天数不能为空";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            //删除子表
            oCN.RunProc("delete from JIT_NeedMaterPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
            int i = 1;
            //插入子表
            foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub)
@@ -616,7 +751,7 @@
                oCN.RunProc("insert into JIT_NeedMaterPlanConfigBillSub(HInterID,HEntryID,HRemark,HWorkShopID,HWorkShopName,HMaterID," +
                    "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
                    "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" +
                    $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HWorkShopName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
                    $"({omdelMian.HInterID}, {i}, '{oSub.HRemark}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HWorkShopName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
                    $" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," +
                    $" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) ");
                i++;