From 356fb43b6b458f33d2c6ba6b13d8729f7f656ea1 Mon Sep 17 00:00:00 2001
From: 沈泽 <211959439@qq.com>
Date: 星期五, 10 九月 2021 16:44:17 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 DAL/生产管理/设备管理/ClsSb_EquipDotCheckBill.cs                      |   10 +-
 WebAPI/Controllers/SBGL/Sb_EquipDotCheckPlanBillController.cs |    6 +-
 WebAPI/DLL/ClsSc_ICMOBillWorkQtyStatus_Tmp.cs                 |    3 +
 WebAPI/WebAPI.csproj.user                                     |    2 
 WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs     |    6 +-
 DAL/MES/ClsSc_MESMaterToSourceBill .cs                        |   43 +++++++++++++
 WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs     |   88 ++++++++++++++++++++++++++++-
 7 files changed, 141 insertions(+), 17 deletions(-)

diff --git a/DAL/MES/ClsSc_MESMaterToSourceBill .cs b/DAL/MES/ClsSc_MESMaterToSourceBill .cs
index 83efea5..d13ee07 100644
--- a/DAL/MES/ClsSc_MESMaterToSourceBill .cs
+++ b/DAL/MES/ClsSc_MESMaterToSourceBill .cs
@@ -58,7 +58,7 @@
                 ",HMainSourceBillType=" + omodel.HMainSourceBillType.ToString() +
                 ",HMainSourceInterID=" + omodel.HMainSourceInterID.ToString() +
                 ",HMainSourceEntryID=" + omodel.HMainSourceEntryID.ToString() +
-                ",HMainSourceBillNo=" + omodel.HMainSourceBillNo.ToString() +
+                ",HMainSourceBillNo='" + omodel.HMainSourceBillNo.ToString() +"'"+
                 ",HSourceID=" + omodel.HSourceID.ToString() +
                 ",HProcID=" + omodel.HProcID.ToString() +
                 ",HMaterID=" + omodel.HMaterID.ToString() +
@@ -88,7 +88,7 @@
                       ",'" + oSub.HBarCode + "','" + oSub.HBarCode_Pack + "','" + oSub.HBillNo_bak + "'" +
                       ") ");
                 }
-                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                sReturn = omodel.HInterID.ToString();
                 oCn.Commit();
                 return true;
             }
@@ -265,6 +265,45 @@
             }
         }
 
+        //鍒犻櫎鍗曟嵁
+        public override bool DeleteBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                //鍒ゆ柇鏄惁鍏佽鍒犻櫎
+                DataSet ds = oCn.RunProcReturn("exec h_p_Sc_MaterToSourceBill_DelCtrl @HInterId=" + lngBillKey + "", "h_p_Sc_MaterToSourceBill_DelCtrl");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    sReturn = "鏃犻獙璇佹暟鎹紒";
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    return false;
+                }
+
+                //鍒犻櫎鍏宠仈鍏崇郴
+                oCn.RunProc("exec h_p_Sc_MaterToSourceBill_DelRelation @HInterId=" + lngBillKey + "");
+
+                //鍒犻櫎鏄庣粏琛�
+                oCn.RunProc("Delete From " + MvarItemKeySub + "  where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎涓昏〃
+                oCn.RunProc("Delete From " + MvarItemKey + "  where HInterID=" + lngBillKey.ToString());
+
+                sReturn = "鍒犻櫎鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
         //瀹℃牳
         public bool CheckBill(Int64 lngBillKey, ref string sReturn)
         {
diff --git "a/DAL/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSb_EquipDotCheckBill.cs" "b/DAL/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSb_EquipDotCheckBill.cs"
index b85a9b9..2e4abe6 100644
--- "a/DAL/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSb_EquipDotCheckBill.cs"
+++ "b/DAL/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\276\345\244\207\347\256\241\347\220\206/ClsSb_EquipDotCheckBill.cs"
@@ -67,14 +67,14 @@
                       " (HInterID,HEntryID," +
                       "HCloseMan,HEntryCloseDate,HCloseType,HRemark," +
                       "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney," +
-                      "HDotCheckItem,HDotCheckPart,HClaim," +
+                      "HDotCheckItemID,HDotCheckItem,HDotCheckPart,HClaim," +
                       "HManagerID,HManagerNumber" +
                       ") values("
-                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + 
-                      ",'" + oSub.HCloseMan + "','"+oSub.HEntryCloseDate+"'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
+                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() +
+                      ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
                       "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
-                      ",'" + oSub.HDotCheckItem + "','"+oSub.HDotCheckPart+"','"  + oSub.HClaim +
-                      "'," + oSub.HManagerID.ToString()+",'" +oSub.HManagerNumber+"'"+
+                      ",'" + oSub.HDotCheckItemID + "','" + oSub.HDotCheckItem + "','" + oSub.HDotCheckPart + "','" + oSub.HClaim +
+                      "'," + oSub.HManagerID.ToString() + ",'" + oSub.HManagerNumber + "'" +
                       ") ");
                 }
                 //
diff --git a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs
index df7dedb..87a6e09 100644
--- a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs
+++ b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckBillController.cs
@@ -82,7 +82,7 @@
 
         #region 璁惧鐐规璁板綍琛� 淇濆瓨/缂栬緫
         /// <summary>
-        /// 淇濆瓨妯″叿缁翠慨鍗�
+        /// 鐐规璁板綍琛� 淇濆瓨
         /// </summary>
         /// <param name="msg"></param>
         /// <returns></returns>
@@ -318,7 +318,7 @@
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select 鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName  from h_v_Sb_EquipDotCheckBillList", "h_v_Sb_EquipDotCheckBillList");
+                    ds = oCN.RunProcReturn("select 鐐规椤圭洰ID HDotCheckItemID,鐐规椤圭洰浠g爜 as HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName  from h_v_Sb_EquipDotCheckBillList", "h_v_Sb_EquipDotCheckBillList");
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
@@ -326,7 +326,7 @@
                 }
                 else
                 {
-                    string sql1 = "select 鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName  from h_v_Sb_EquipDotCheckBillList where 1 = 1 ";
+                    string sql1 = "select 鐐规椤圭洰ID HDotCheckItemID,鐐规椤圭洰浠g爜 as HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜虹紪鐮� HManagerCode,璐熻矗浜� HManagerName  from h_v_Sb_EquipDotCheckBillList where 1 = 1 ";
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckBillList");
                     objJsonResult.code = "0";
diff --git a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckPlanBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckPlanBillController.cs
index dc8b188..b36ced9 100644
--- a/WebAPI/Controllers/SBGL/Sb_EquipDotCheckPlanBillController.cs
+++ b/WebAPI/Controllers/SBGL/Sb_EquipDotCheckPlanBillController.cs
@@ -301,7 +301,7 @@
             return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
         }
         #endregion
-        #region[璁惧鐐规璁″垝琛ㄧ紪杈戞椂鑾峰彇琛ㄩ鏁版嵁]
+        #region[璁惧鐐规璁″垝琛ㄧ紪杈戞椂鑾峰彇琛ㄤ綋鏁版嵁]
         [Route("Sb_EquipDotCheckPlanBill/Sb_EquipDotCheckPlanBillListProjectDetai")]
         [HttpGet]
         public object Sb_EquipDotCheckPlanBillListProjectDetai(string sqlWhere)
@@ -312,7 +312,7 @@
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select 鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜轰唬鐮� HManagerID,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckPlanBillList", "h_v_Sb_EquipDotCheckPlanBillList");
+                    ds = oCN.RunProcReturn("select 鐐规椤圭洰ID  HDotCheckItemID,鐐规椤圭洰浠g爜  HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜轰唬鐮� HManagerCode,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckPlanBillList", "h_v_Sb_EquipDotCheckPlanBillList");
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
@@ -320,7 +320,7 @@
                 }
                 else
                 {
-                    string sql1 = "select 鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜轰唬鐮� HManagerID,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckPlanBillList where 1 = 1 ";
+                    string sql1 = "select 鐐规椤圭洰ID  HDotCheckItemID,鐐规椤圭洰浠g爜  HDotCheckCode ,鐐规椤圭洰 HDotCheckItem,鐐规閮ㄤ綅 HDotCheckPart ,鍏蜂綋瑕佹眰 HClaim,琛ㄤ綋澶囨敞 HRemark,璐熻矗浜篒D HManagerID,璐熻矗浜轰唬鐮� HManagerCode,璐熻矗浜� HManagerName from h_v_Sb_EquipDotCheckPlanBillList where 1 = 1 ";
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckPlanBillList");
                     objJsonResult.code = "0";
diff --git a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
index af0c38b..c8db589 100644
--- a/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_MaterToSourceBillController.cs
@@ -40,13 +40,13 @@
             {
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillList " + sWhere, "h_v_Sc_MaterToSourceBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillMain " + sWhere, "h_v_Sc_MaterToSourceBillMain");
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_Sc_MaterToSourceBillList where 1 = 1 ";
+                    string sql1 = "select * from h_v_Sc_MaterToSourceBillMain where 1 = 1 ";
                     string sql = sql1 + sWhere;
-                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillList");
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillMain");
                 }
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -132,6 +132,87 @@
                 objJsonResult.data = null;
             }
             return objJsonResult;
+        }
+        #endregion
+
+        #region [涓婃枡闃查敊鍗曞垹闄ゅ姛鑳絔
+        /// <summary>
+        /// 寮�宸ュ崟鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("Sc_MaterToSourceBill/DeltetMaterToSourceBill")]
+        [HttpGet]
+        public object DeltetMaterToSourceBill(string HInterID, string UserName)
+        {
+            DBUtility.ClsPub.CurUserName = UserName;
+            //缂栬緫鏉冮檺
+            //if (!DBUtility.ClsPub.Security_Log("MES_MaterToSourceBill_Delete", 1, true, DBUtility.ClsPub.CurUserName))
+            //{
+            //    objJsonResult.code = "0";
+            //    objJsonResult.count = 0;
+            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+            //    objJsonResult.data = null;
+            //    return objJsonResult;
+            //}
+
+
+            Int64 lngBillKey = 0;
+            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+            if (lngBillKey == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            DAL.ClsSc_MESMaterToSourceBill oBill = new DAL.ClsSc_MESMaterToSourceBill();
+            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+            {
+                if (oBill.omodel.HBillStatus > 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵��,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (oBill.omodel.HChecker != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                if (IsDete)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍗曟嵁鏈壘鍒�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
         }
         #endregion
 
@@ -515,6 +596,7 @@
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //杩斿洖涓籌D
                     objJsonResult.Verify = "N";
                 }
                 if (bResult)
diff --git a/WebAPI/DLL/ClsSc_ICMOBillWorkQtyStatus_Tmp.cs b/WebAPI/DLL/ClsSc_ICMOBillWorkQtyStatus_Tmp.cs
index 4d545ba..f368353 100644
--- a/WebAPI/DLL/ClsSc_ICMOBillWorkQtyStatus_Tmp.cs
+++ b/WebAPI/DLL/ClsSc_ICMOBillWorkQtyStatus_Tmp.cs
@@ -98,6 +98,9 @@
                 "," + omodel.HSourceInterID.ToString() + "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSplitNO + "','" + omodel.HSourceBillType + "'" +
                 "," + omodel.HRelationInterID.ToString() + "," + omodel.HRelationEntryID.ToString() + ",'" + omodel.HRelationBillNo + "'," + omodel.HReportEntryID.ToString() + 
                 ") ");
+                double sumqty = omodel.HQty + omodel.HBadQty + omodel.HWasterQty;  //汇报数量+不良+报废
+                //回写生产状态临时表Sc_ICMOBillStatus_Tmp拆分汇报数量 HSplitRelationQty
+                oCn.RunProc("update Sc_ICMOBillStatus_Tmp set HSplitRelationQty=HSplitRelationQty+"+ sumqty + "  where HICMOBillNo='"+omodel.HICMOBillNo+"'  and HSourceID='"+omodel.HSourceID+"' and  HICMOInterID='"+omodel.HICMOInterID+"' and HICMOEntryID='"+omodel.HICMOEntryID+"'");
 
                 //再次验证 保存是否 合理
                 DataSet ds = oCn.RunProcReturn("exec h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl @HInterId=" + omodel.HInterID + "", "h_p_JIT_ICMOBillWorkQtyStatus_SaveCtrl");
diff --git a/WebAPI/WebAPI.csproj.user b/WebAPI/WebAPI.csproj.user
index e627b17..c934955 100644
--- a/WebAPI/WebAPI.csproj.user
+++ b/WebAPI/WebAPI.csproj.user
@@ -7,7 +7,7 @@
     <WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
     <WebStackScaffolding_LayoutPageFile />
     <WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
-    <NameOfLastUsedPublishProfile>D:\Git浠撳簱\椤圭洰\MESWMS\MES-WEB-API\WebAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
+    <NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
     <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
     <UseIISExpress>false</UseIISExpress>
     <Use64BitIISExpress />

--
Gitblit v1.9.1