From 0ea85f05fb9248216de064fee4ccd592640fb76b Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期六, 28 二月 2026 13:13:59 +0800
Subject: [PATCH] 新增 根据模块获取该模块下需要显示消息标识数量 接口

---
 WebAPI/Controllers/生产管理/质量汇报单/Sc_QualityReportBillController.cs |  198 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 152 insertions(+), 46 deletions(-)

diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\350\264\250\351\207\217\346\261\207\346\212\245\345\215\225/Sc_QualityReportBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\350\264\250\351\207\217\346\261\207\346\212\245\345\215\225/Sc_QualityReportBillController.cs"
index bc57896..172fe19 100644
--- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\350\264\250\351\207\217\346\261\207\346\212\245\345\215\225/Sc_QualityReportBillController.cs"
+++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\350\264\250\351\207\217\346\261\207\346\212\245\345\215\225/Sc_QualityReportBillController.cs"
@@ -1,6 +1,7 @@
 锘縰sing Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Pub_Class;
+using SyntacticSugar.constant;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -246,10 +247,12 @@
                 BillNew.HMaker = mainList[0].HMaker;
                 BillNew.HMakeDate = mainList[0].HMakeDate;
                 BillNew.HReportType = mainList[0].HReportType;
-                BillNew.HSourceBillNo = mainList[0].HICMOBillNo;
-                BillNew.HSourceInterID = mainList[0].HICMOInterID;
+                BillNew.HSourceBillNo = mainList[0].HSourceBillNo;
+                BillNew.HSourceInterID = mainList[0].HSourceInterID;
+                BillNew.HSourceEntryID = mainList[0].HSourceEntryID;
                 BillNew.HSourceBillType = mainList[0].HSourceBillType;
                 BillNew.HBadReasonHQty = mainList[0].HBadReasonHQty;
+                BillNew.HQty = DBUtility.ClsPub.isLong(mainList[0].HQty);
                 oCN.BeginTran();
                 //涓存椂琛�
                 oCN.RunProc("Insert Into Sc_ICMOBillQualityStatus_Tmp " +
@@ -257,13 +260,13 @@
                     ",HProcExchBillNo,HProcExchInterID,HProcExchEntryID,HProcID,HMaterID" +
                     ",HSourceID,HGroupID,HDeptID,HCheckManID,HBadReasonID,HBarCode" +
                     ",HMaker,HMakeDate,HBillType,HReportType,HSourceBillNo" +
-                    ",HSourceInterID,HSourceBillType,HICMOEntryID,HSourceEntryID,HBadReasonHQty" +
+                    ",HSourceInterID,HSourceBillType,HICMOEntryID,HSourceEntryID,HBadReasonHQty,HQty" +
                 ") " +
                 " values(" + BillNew.HInterID + ",'" + BillNew.HBillNo + "','" + BillNew.HDate + "','" + BillNew.HICMOBillNo + "'," + BillNew.HICMOInterID + 
                 ",'" + BillNew.HProcExchBillNo + "'," + BillNew.HProcExchInterID + "," + BillNew.HProcExchEntryID + "," + BillNew.HProcID + "," + BillNew.HMaterID +
                 "," + BillNew.HSourceID + "," + BillNew.HGroupID + "," + BillNew.HDeptID + "," + BillNew.HCheckManID + "," + BillNew.HBadReasonID + ",'" + BillNew.HBarCode + "'" +
                 ",'" + BillNew.HMaker + "','" + BillNew.HMakeDate + "','" + BillNew.HBillType + "','" + +BillNew.HReportType + "','" +BillNew.HSourceBillNo + "'" +
-                "," + BillNew.HSourceInterID + ",'" + BillNew.HSourceBillType + "'," + BillNew.HICMOEntryID + "," + BillNew.HICMOEntryID + "," + BillNew.HBadReasonHQty +
+                "," + BillNew.HSourceInterID + ",'" + BillNew.HSourceBillType + "'," + BillNew.HICMOEntryID + "," + BillNew.HSourceEntryID + "," + BillNew.HBadReasonHQty + "," + BillNew.HQty +
                 ") ");
                 sReturn = "鎵爜鎴愬姛锛�";
                 oCN.Commit();
@@ -640,7 +643,7 @@
         #region 鎻愪氦淇濆瓨锛屽瓨涓诲瓙琛ㄥ強鏄庣粏琛�
         [Route("Sc_QualityReportBill/set_SaveBill")]
         [HttpGet]
-        public object set_SaveBill(long HInterID,string HBillNo, string HChecker)
+        public object set_SaveBill(long HInterID,string HBillNo, string HChecker,string HBillSubType)
         {
             try
             {
@@ -672,11 +675,11 @@
                 ds = oCN.RunProcReturn(sql, "Sc_QualityReportBillSub");
                 if (ds.Tables[0].Rows.Count>0)
                 {
-                    oCN.RunProc("exec h_p_save_Sc_QualityReportBillSum " + HInterID + "");
+                    oCN.RunProc("exec h_p_save_Sc_QualityReportBillSum '" + HInterID + "','" + HBillSubType +"'");
                 }
                 else
                 {
-                    oCN.RunProc("exec h_p_save_Sc_QualityReportBill " + HInterID + "");
+                    oCN.RunProc("exec h_p_save_Sc_QualityReportBill '" + HInterID + "','" + HBillSubType + "'");
                 }
                 
                 //鍒ゆ柇鏄惁鍏佽淇濆瓨锛屼笉鍏佽鍒欏洖婊�
@@ -695,6 +698,7 @@
 
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
+                    oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
@@ -703,6 +707,7 @@
                 }
                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                 {
+                    oCN.RollBack();
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
@@ -799,7 +804,7 @@
                     string subSql = "Insert into Sc_QualityReportBillSub " +
                  " (HInterID,HEntryID,HBillNo_bak,HRemark" +
                  ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
-                 ",HMaterID,HUnitID,HQty,HResult,HEmpID,HSourceID,HProcID,HBadReasonID,HBadReasonNumber,HGroupID" +
+                 ",HMaterID,HUnitID,HQty,HResult,HEmpID,HSourceID,HProcID,HBadReasonID,HBadReasonNumber,HBadPhenomenaID,HGroupID" +
                  ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcExchInterID,HProcExchEntryID,HProcExchBillNo" +
                  ",HBarCode,HReportType" +
                  ",HAddr,HMaker,HMakeDate" +
@@ -824,6 +829,7 @@
                  "," + oSub.HProcID.ToString() + "" +
                  "," + oSub.HBadReasonID.ToString() + "" +
                  ",'" + oSub.HBadReasonNumber.ToString() + "'" +
+                "," + oSub.HBadPhenomenaID.ToString() + "" +
                  ",'" + oSub.HGroupID.ToString() + "'" +
 
                  "," + oSub.HICMOInterID.ToString() + "" +
@@ -917,6 +923,61 @@
                 objJsonResult.Message = "Exception锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇璐ㄩ噺姹囨姤鍗曞垪琛� 鍒嗛〉鍒楄〃
+        [Route("Sc_QualityReportBill/getSc_QualityReportBillPage")]
+        [HttpGet]
+        public json getSc_QualityReportBillPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 3, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sc_QualityReportBillMainList " + page + "," + size + ",''", "h_p_Sc_QualityReportBillMainList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sc_QualityReportBillMainList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_QualityReportBillMainList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
             }
         }
         #endregion
@@ -1539,8 +1600,30 @@
                 //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
                 if (IsAudit == 0) //鍏抽棴鎻愪氦
                 {
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Sc_QualityReportBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_QualityReportBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
                     //鍏抽棴鎻愪氦
-                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_QualityReportBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -1559,8 +1642,31 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Sc_QualityReportBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_QualityReportBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
                     //鍙嶅叧闂彁浜�
-                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_QualityReportBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -1745,15 +1851,15 @@
             try
             {
                 List<object> columnNameList = new List<object>();
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                ////鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
                 ReportWorkDemandPlanBill Report = JsonConvert.DeserializeObject<ReportWorkDemandPlanBill>(sWhere);
                 ds = oCN.RunProcReturn($"exec h_p_Sc_StationOutBillMain  '{Report.HBeginDate}','{Report.HEndDate}','{Report.HNumber}','{Report.HName}','{Report.HProcName}','{Report.HEquipName}','{Report.HBactNo}'", "h_p_Sc_StationOutBillMain");
 
@@ -1800,15 +1906,15 @@
             try
             {
                 List<object> columnNameList = new List<object>();
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                ////鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
                 ReportWorkDemandPlanBill1 Report = JsonConvert.DeserializeObject<ReportWorkDemandPlanBill1>(sWhere);
                 ds = oCN.RunProcReturn($"exec h_p_Sc_StationOutBillMonth  '{Report.HYear}','{Report.HWorkCenter}','{Report.HName}', '{Report.HBeginDate}','{Report.HEndDate}'", "h_p_Sc_StationOutBillMonth");
 
@@ -1847,15 +1953,15 @@
             try
             {
                 List<object> columnNameList = new List<object>();
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                ////鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
@@ -1903,15 +2009,15 @@
             try
             {
                 List<object> columnNameList = new List<object>();
-                //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                ////鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
 
                 if (sWhere == null || sWhere.Equals(""))
                 {

--
Gitblit v1.9.1