From e42e0a80cc8e79a2a92a88c1e118157644630a13 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 05 六月 2024 16:44:12 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/SCGL/日计划管理/Sc_JIT_ComplementGoodBillController.cs |  112 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 71 insertions(+), 41 deletions(-)

diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/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"
index a16948b..b2321bb 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/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"
@@ -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;
+                    }
                 }
             }
 
@@ -601,7 +608,15 @@
                     {
                         row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                     }
-                    tb2.Rows.Add(row);
+                    //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
+                    {
+                        continue;
+                    }
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }
                 }
 
 
@@ -729,13 +744,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 +760,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 + ",鐗╂枡浠g爜:"+ HMaterNumer + ",涓嶅瓨鍦紒";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -767,7 +782,7 @@
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,璁¢噺鍗曚綅涓嶅瓨鍦紒";
+                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,璁¢噺鍗曚綅:"+ HUntilName + ",涓嶅瓨鍦紒";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -811,7 +826,7 @@
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "绗�" + index + "琛�,IT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�";
+                            objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -839,8 +854,8 @@
                     }
                     else
                     {
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
                         objJsonResult.data = null;
                         return objJsonResult;
@@ -871,7 +886,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,15 +914,13 @@
                 }
 
                 oCN.BeginTran();
-
+                int i = 1;
                 foreach (Dictionary<string, string> item in list)
                 {
-                    long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
-                    string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
-                    string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
                     string HSupID = item["HSupID"].ToString();//渚涘簲鍟�
-                    string HSupplierName = item["渚涘簲鍟�"].ToString();
                     string HMaterID = item["HMaterID"].ToString();//鐗╂枡ID
+                    string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+                    string HSupplierName = item["渚涘簲鍟�"].ToString();
                     string HMaterName = item["鐗╂枡鍚嶇О"].ToString();
                     string HMaterModel = item["瑙勬牸鍨嬪彿"].ToString();
                     string HUnitID = item["HUnitID"].ToString();//璁¢噺鍗曚綅
@@ -922,17 +935,34 @@
                     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," +
-                   "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
-                   "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)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)} ,{HUnitID},{JIMLC})");
+                    ds = oCN.RunProcReturn("select * from Cg_PODemandPlanConfigBillSub where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID, "Cg_PODemandPlanConfigBillSub");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+
+                        long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+                        string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+
+
+                        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,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})";
+                        //涓昏〃
+                        oCN.RunProc(sql);
+                        //瀛愯〃
+                        oCN.RunProc(sql1);
+                    }
+                    else
+                    {
+                        oCN.RunProc("	update  Cg_PODemandPlanConfigBillSub set HLeadTime=" + JISLT + "  where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID);
+                    }
+               
+                    i++;
                 }
               
                 oCN.Commit();
@@ -945,7 +975,7 @@
             }
             catch (Exception e)
             {
-                oCN.RollBack();
+                LogService.Write(e);
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.ToString();

--
Gitblit v1.9.1