From 4f09261581ae965fd224985d04aa565e4c310920 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 07 四月 2025 17:41:26 +0800
Subject: [PATCH] 设备单据模块优化(设备保养计划单、设备保养记录单、设备点检计划单、设备点检记录单、设备工艺参数点检表、设备停机单、设备开机单、设备故障登记单、设备维修派工单、设备维修记录单、设备维修签到单、设备维修验收单)

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  101 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 78 insertions(+), 23 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index dd49e00..2a48c10 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -15,6 +15,7 @@
     {
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
         DataSet ds;
 
         #region 宸ュ簭鍗曞搧涓嶈壇閲囬泦  鐢ㄦ埛鏌ヨ鍏宠仈瀛楁
@@ -183,14 +184,31 @@
 
                 if (ds.Tables[0].Rows.Count == 0)//鏂板
                 {
-                    //涓昏〃
-                    oCN.RunProc(@"Insert Into Sc_QualityReportBillMain   
-(HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate
-,HYear,HPeriod,HRemark,HMaker,HMakeDate
-,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
+                    if (HResult== "寰憰鍝�")
+                    {
+                        //涓昏〃
+                        oCN.RunProc(@"Insert Into Sc_QualityReportBillMain   
+                    (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate
+                    ,HYear,HPeriod,HRemark,HMaker,HMakeDate
+                    ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
+                        values('3717','3717-1',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+                        "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
+                        ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') ");
+                        //閲嶆柊缁橦Result璧嬪��
+                        HResult = "";
+                    }
+                    else
+                    {
+                        //涓昏〃
+                        oCN.RunProc(@"Insert Into Sc_QualityReportBillMain   
+                    (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate
+                    ,HYear,HPeriod,HRemark,HMaker,HMakeDate
+                    ,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
                         values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
-                    "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
-                    ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') ");
+                        "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
+                        ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') ");
+                    }
+                    
 
                 }
                
@@ -280,18 +298,32 @@
 (HInterID,HENTRYID,HBillNo_bak,HEmpID,HBarCode,HBadReasonID,HAddr,HMaker,HMakeDate
 ,HMaterID,HUnitID,HRemark,HSourceID,HICMOInterID,HICMOEntryID,HICMOBillNo,HReportType
 ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
-,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo) 
+,HQty,HResult,HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HProcID) 
 values({HInterID},1,'{oSub.HBillNo_bak}',{oSub.HEmpID},'{oSub.HBarCode}',{oSub.HBadReasonID},'','{oSub.HMaker}','{oSub.HMakeDate}'
 ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HReportType}
 ,0,0,'','',0,0
-,0,'{HResult}',{oSub.HProcExchInterID},{oSub.HProcExchEntryID},'{oSub.HProcExchBillNo}')");
+,1,'{HResult}',{oSub.HProcExchInterID},{oSub.HProcExchEntryID},'{oSub.HProcExchBillNo}',{oSub.HProcID})");
 
             //淇敼鏉$爜琛ㄧ殑鐘舵��
             oCN.RunProc("update Gy_BarCodeBill set HStatus='"+ HResult + "' where HBarCode='"+ oSub.HBarCode + "'");
 
             //淇敼鍑虹珯鍗曠殑 涓嶈壇 鎶ュ簾鏁伴噺
-            if (HResult == "涓嶈壇") {
-                oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid);
+            if (HResult == "涓嶈壇")
+            {
+                LogService.Write("绫诲瀷:" + oSub.HBadTypeID);
+                //宸ュ簾
+                if (oSub.HBadTypeID == 3)
+                {
+                    oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Work+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid);
+                }//鏂欏簾
+                else if (oSub.HBadTypeID == 4)
+                {
+                    oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HWasterQty_Mater+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid);
+                }//杩斿伐
+                else if (oSub.HBadTypeID == 6)
+                {
+                    oCN.RunProc("update Sc_StationOutBillMain set HBadCount+=1,HBackWorkQty+=1  where HProcExchBillNo='" + oSub.HProcExchBillNo + "' and HProcID=" + oSub.HProcID + " and HInterID=" + linterid);
+                }
             }
             else if (HResult == "鎶ュ簾")
             {
@@ -329,16 +361,27 @@
                     HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
                 }
 
-                //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚︽槸寮�宸�
-                ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0'", "Sc_ICMOBillStatus_Tmp");
-                if (ds.Tables[0].Rows.Count == 0)
+
+
+                //瀹㈡埛鍒跺畾
+                string sErr = "";
+                if (oSystemParameter.ShowBill(ref sErr))
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗″彿:" + HBarCode + ",娴佽浆鍗℃湭寮�宸�!";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
+                    {
+                        //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚︽槸寮�宸�
+                        ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0'", "Sc_ICMOBillStatus_Tmp");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗″彿:" + HBarCode + ",娴佽浆鍗℃湭寮�宸�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
                 }
+
 
                 ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomList '" + HBarCode + "'," + HProcID, "h_p_Gy_BarCodeBillBomList");
                 if (ds.Tables[0].Rows.Count == 0)
@@ -585,7 +628,7 @@
                 sMainStr = "[" + sMainStr + "]";
                 List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(sMainStr);
 
-                ds = oCN.RunProcReturn("select  HCenterID from Sc_ProcessExchangeBillSub WITH(NOLOCK) where HInterID=" + list[0].HProcExchInterID + " and HEntryID=" + list[0].HProcExchEntryID, "Sc_ProcessExchangeBillSub");
+                ds = oCN.RunProcReturn("select HCenterID from Sc_ProcessExchangeBillSub WITH(NOLOCK) where HInterID=" + list[0].HProcExchInterID + " and HEntryID=" + list[0].HProcExchEntryID, "Sc_ProcessExchangeBillSub");
                 if (ds.Tables[0].Rows.Count > 0)
                 {
                     list[0].HCenterID = long.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString());
@@ -684,7 +727,7 @@
                     ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
                         ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID,HShiftsID" +
                     ") " +
-                    " values('" + BillType + "','"+ HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
+                    " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
                     "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
                     ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID +
@@ -1657,8 +1700,20 @@
                         if (dataSet.Tables[0].Rows.Count > 0)
                         {
                             string HOutInterID = dataSet.Tables[0].Rows[0][0].ToString();
-
-                            oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1 where HInterID='" + HOutInterID + "'");
+                            //鏂帿灏旂殑鎯呭喌 鍒� 宸ュ簾鏂欏簾 杩斿伐
+                            //宸ュ簾
+                            if (subLsit[0].HBadTypeID == 3)
+                            {
+                                oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HWasterQty_Work-=1  where HInterID='" + HOutInterID + "'");
+                            }//鏂欏簾
+                            else if (subLsit[0].HBadTypeID == 4)
+                            {
+                                oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HWasterQty_Mater-=1 where HInterID='" + HOutInterID + "'");
+                            }//杩斿伐
+                            else if (subLsit[0].HBadTypeID == 6)
+                            {
+                                oCN.RunProc("update Sc_StationOutBillMain set HBadCount-=1,HBackWorkQty-=1 where HInterID='" + HOutInterID + "'");
+                            }
                         }
                         else
                         {

--
Gitblit v1.9.1