WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/Sc_JIT_ComplementGoodBillController.cs
@@ -21,6 +21,7 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        #region æ—¥è®¡åˆ’平台基础资料 è½¦é—´ä»“库对照
@@ -419,6 +420,8 @@
        public json AddPODBillSub(string msg3)
        {
            string Ret = "";
            oSystemParameter.ShowBill(ref Ret);
            omodelPODsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanConfigBillSub>>(msg3);
            foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub)
@@ -447,21 +450,25 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null)
                if (oSystemParameter.omodel.WMS_CampanyName != "帅威")
                {
                    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;
                    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;
                    }
                }
            }
@@ -729,13 +736,13 @@
                        //查询供应商
                        ds = oCN.RunProcReturn("select * from Gy_Supplier where  HNumber='" + HSupNumer + "' and HName='" + HSupName + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
                        ds = oCN.RunProcReturn("select * from Gy_Supplier where  HNumber='" + HSupNumer + "'  and HUSEORGID=" + HORGid + "", "Gy_Supplier");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,供应商不存在!";
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,供应商:"+ HSupName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -745,13 +752,13 @@
                        }
                        //查询物料
                        ds = oCN.RunProcReturn("select * from Gy_Material where  HNumber='" + HMaterNumer + "' and HName='" + HMaterName + "' and HModel='" + HMaterModel + "'  and HUSEORGID=" + HORGid + "", "Gy_Material");
                        ds = oCN.RunProcReturn("select * from Gy_Material where  HNumber='" + HMaterNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Material");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,物料不存在!";
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,物料:"+ HMaterName + ",物料代码:"+ HMaterNumer + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -767,7 +774,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,计量单位不存在!";
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,计量单位:"+ HUntilName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -811,7 +818,7 @@
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,IT到货前置期(天)为空!";
                            objJsonResult.Message = "第" + index + "行,JIT到货前置期(天)为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
@@ -871,7 +878,7 @@
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
@@ -899,7 +906,7 @@
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//获得一个新的id
@@ -922,17 +929,22 @@
                    string JIMLC = item["JIT最小起送量"].ToString();
                    string HRemark = item["备注"].ToString();
                    int i = 1;
                    //主表
                    oCN.RunProc("insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" +
                        $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})");
                    //子表
                    oCN.RunProc("insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," +
                    string sql = "insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" +
                        $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})";
                    string sql1 = "insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," +
                   "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
                   "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" +
                   $"({HInterID}, {i}, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," +
                   $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},0,{(JITPBCC == "" ? "0" : JITPBCC)}," +
                   $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)}) ");
                   "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)values" +
                   $"({HInterID}, 1, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," +
                   $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," +
                   $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{JIMLC})";
                    LogService.Write("sql" + i + ":" + sql);
                    LogService.Write("sql1" + i + ":" + sql1);
                   //主表
                   oCN.RunProc(sql);
                    //子表
                    oCN.RunProc(sql1);
                    i++;
                }
              
                oCN.Commit();
@@ -945,7 +957,7 @@
            }
            catch (Exception e)
            {
                oCN.RollBack();
                LogService.Write(e);
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();