From dd5ee46ce65024040796301aef1679a4df199c14 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期三, 03 十二月 2025 17:16:09 +0800
Subject: [PATCH] 增加上模单app保存方法和校验方法 增加量具临期预警报表

---
 WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs |  239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 237 insertions(+), 2 deletions(-)

diff --git a/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs
index 4658a51..9bd958b 100644
--- a/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs
+++ b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs
@@ -328,10 +328,10 @@
 
                 oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub   
                    (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
-                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo)
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo,HScanDate,HBarCode)
                     values("
                      + HInterID + ",'"+ HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty 
-                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() +
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() + "','getdate()','" + oSub.HBarCode.ToString() + 
                      "') ");
             }
 
@@ -2471,5 +2471,240 @@
         }
 
         #endregion
+
+        #region 涓婃ā鍗� APP鏂板
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill_APP")]
+        [HttpPost]
+        public object AddSc_MouldUpperBill_APP([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain_APP(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 = ds.Tables[0];
+            return objJsonResult;
+        }
+
+        public json AddBillMain_APP(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗 
+            string user = sArray[3].ToString();//鐢ㄦ埛鍚�
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsSc_MouldUpperBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillMain>>(msg2);
+                string HBillType = "3846";
+                long HInterID = mainList[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = mainList[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//鏃ユ湡
+                int HYear = DateTime.Now.Year;
+                double HPeriod = DateTime.Now.Month;
+                string HRemark = mainList[0].HRemark;//澶囨敞
+                string HMaker = mainList[0].HMaker;//鍒跺崟浜�
+                int HOrgID = mainList[0].HOrgID;  //缁勭粐
+                Int64 HDeptID = mainList[0].HDeptID;
+                Int64 HEmpID = mainList[0].HEmpID;
+                Int64 HMangerID = mainList[0].HMangerID;
+
+                ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Qj_Sc_MouldUpperBillList");
+
+                if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板
+                {
+                    //淇濆瓨鍓嶆帶鍒�
+                    objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 1);
+                    if (objJsonResult.count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //涓昏〃
+                    oCN.RunProc(@"Insert Into Sc_MouldUpperBillMain   
+                   (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate
+                   , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID
+                   , HDeptID, HEmpID, HMangerID)" +
+                    " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                    "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID +
+                    "," + HDeptID + "," + HEmpID + "," + HMangerID + ") ");
+
+                }
+                else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
+                {
+                    //淇濆瓨鍓嶆帶鍒�
+                    objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 2);
+                    if (objJsonResult.count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //淇敼
+                    oCN.RunProc("update Sc_MouldUpperBillMain  set " +
+                       "HDate='" + HDate +
+                       "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
+                       "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'");
+
+                    //鍒犻櫎瀛愯〃
+                    oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'");
+                }
+                //淇濆瓨瀛愯〃
+                objJsonResult = AddBillSub_APP(msg3, HInterID, HBillNo, OperationType);
+                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_APP(string msg3, long HInterID, string HBillNo, Int64 OperationType)
+        {
+            List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg3);
+            int i = 0;
+            foreach (ClsSc_MouldUpperBillSub oSub in DetailColl)
+            {
+                i++;
+
+                oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub   
+                   (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty
+                   , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo,HScanDate,HBarCode)
+                    values("
+                     + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty
+                     + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() + "',getdate(),'" + oSub.HBarCode.ToString() +
+                     "') ");
+            }
+
+            if (OperationType == 1)//鏂板
+            {
+                //淇濆瓨鍚庢帶鍒�
+                objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 1);
+                if (objJsonResult.count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            else
+            {
+                //淇濆瓨鍚庢帶鍒�
+                objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 2);
+                if (objJsonResult.count == 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;
+        }
+
+        #endregion
+
+        #region 涓婃ā鍗曟壂鎻忔潯鐮佹煡璇㈡槸鍚﹀瓨鍦� 骞舵牎楠屼骇鍝侀槻閿欎俊鎭�
+        [Route("Sc_MouldUpperBill/GetBarCode_FC")]
+        [HttpGet]
+        public object GetBarCode_FC(string HBarCode, int HMaterID)
+        {
+            try
+            {
+              
+                ds = oCN.RunProcReturn("exec h_p_Sc_MouldFill_Verification '" + HBarCode + "','" + HMaterID + "'", "h_p_Sc_MouldFill_Verification");
+                
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏌ユ棤鏁版嵁锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;  //澶辫触锛�
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;  //鎴愬姛锛�
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }              
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1