1
zrg
2025-12-04 41717d1b7866e69692b2c338000932930e14765f
WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -14990,6 +14990,7 @@
        #region 器具校准记录单
        #region 模具校准记录单表分页列表
        [Route("Gy_QCVerificationBillMain/GetListPage")]
        [HttpGet]
@@ -14998,7 +14999,7 @@
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -15055,7 +15056,7 @@
        public object DeltetGy_QCVerificationBillMain(string HInterID, string user)
        {
            //编辑权限
            if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, user))
            if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Delete", 1, false, user))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
@@ -15096,7 +15097,7 @@
                }
                //删除前控制=========================================      
                string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
                string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
@@ -15117,7 +15118,7 @@
                }
                //==================================================================================  
                bool IsDete = oBill.DeleteBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                bool IsDete = oBill.DeleteBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
@@ -15148,7 +15149,7 @@
        }
        #endregion
        #region [模具维修单审核、反审核]
        #region [器具校准记录单审核、反审核]
        /// <summary>
        /// 
        /// </summary>
@@ -15160,7 +15161,7 @@
        [HttpGet]
        public object AuditQCVerificationBillMain(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sb_MouldRepairWorkBill_Check";
            string ModRightNameCheck = "Gy_QCVerificationBillMain_Check";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
@@ -15237,8 +15238,8 @@
                if (IsAudit == 0) //审核提交
                {
                    //审核前控制=========================================      
                    string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeCheckCtrl");
                    string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_QCVerificationBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
@@ -15260,7 +15261,7 @@
                    }
                    //==================================================================================  
                    if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                    if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
@@ -15272,8 +15273,8 @@
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================        
                    string sql1 = "exec h_p_Sb_MouldRepairWorkBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_MouldRepairWorkBill_BeforeUnCheckCtrl");
                    string sql1 = "exec h_p_Gy_QCVerificationBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_QCVerificationBill_BeforeUnCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
@@ -15293,7 +15294,7 @@
                    }
                    //===========================================================         
                    if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Sb_MouldRepairWorkBill_AfterUnCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                    if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterUnCheckCtrl", CurUserName, ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
@@ -15319,6 +15320,197 @@
        }
        #endregion
        #region 器具校准记录单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldMaintainBill/CloseGy_QCVerificationBill")]
        [HttpGet]
        public object CloseGy_QCVerificationBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Gy_QCVerificationBillMain_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsGy_QCVerificationBillMain oBill = new DAL.ClsGy_QCVerificationBillMain();           //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    string sql = "";
                    //关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Gy_QCVerificationBill_BeforeCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Gy_QCVerificationBill_BeforeCloseCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:关闭前前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //关闭前控制===============================================End===================================================================
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    string sql = "";
                    //反关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Gy_QCVerificationBill_BeforeUnCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Gy_QCVerificationBill_BeforeUnCloseCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:反关闭前前判断失败,无返回信息,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反关闭前控制===============================================End===================================================================
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_QCVerificationBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region[编辑时获取表头数据]
        [Route("Gy_QCVerificationBillMain/Gy_QCVerificationBillMainCheckDetai")]
@@ -15328,7 +15520,7 @@
            if (string.IsNullOrEmpty(HID))
                return new ApiResult<DataSet> { code = -1, msg = "ID不能为空" };
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCVerificationBillMain  where hmainid= " + HID + " ", "h_v_Gy_QCVerificationBillMain");
            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCVerificationBillMain_Edit  where hmainid= " + HID + " ", "h_v_Gy_QCVerificationBillMain");
            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                return new ApiResult<DataSet> { code = -1, msg = "不存在单号" };
            return new ApiResult<DataSet> { code = 1, msg = "查询成功", data = dataSet };
@@ -15340,16 +15532,14 @@
        [HttpGet]
        public object SGy_QCVerificationBillMainListProjectDetai(string sqlWhere)
        {
            DataSet ds, ds1;
            DataSet ds;
            List<object> list = new List<object>();
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = "select HInspectInstruMentID,检验仪器代码 HInspectInstruMentNumber,检验仪器名称 HInspectInstruMentName,生效日期 HBeginDate,失效日期 HEndDate,校准状态 HHCalibrationStatus  from h_v_Gy_QCVerificationBillMain where 1 = 1 " + sqlWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
                string sql = "select HInspectInstruMentID,检验仪器代码 HInspectInstruMentNumber,检验仪器名称 HInspectInstruMentName,生效日期 HBeginDate,失效日期 HEndDate,校准状态 HHCalibrationStatus  from h_v_Gy_QCVerificationBillMain_Edit where 1 = 1 " + sqlWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Gy_QCVerificationBillMain_Edit");
                list.Add(ds.Tables[0]);
@@ -15372,15 +15562,11 @@
        #endregion
        #region 模具维修记录单保存/编辑
        /// <summary>
        /// 保存模具维修单
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Gy_QCVerificationBillMain/SaveGetMQCVerificationBillList")]
        #region 器具校准记录单 保存/编辑
        [Route("Gy_QCVerificationBillMain/SaveGetGy_QCVerificationBill")]
        [HttpPost]
        public object SaveGetMQCVerificationBillList([FromBody] JObject msg)
        public object SaveGetGy_QCVerificationBill([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
@@ -15388,14 +15574,12 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            //string msg5 = sArray[3].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4))
                if (!DBUtility.ClsPub.Security_Log("Gy_QCVerificationBillMain_Edit", 1, false, msg4))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -15412,20 +15596,13 @@
                foreach (Model.ClsGy_QCVerificationBillMain oItem in lsmain)
                {
                    oItem.HMaker = msg4;
                    UserName = msg4;  //制单人
                    DBUtility.ClsPub.CurUserName = msg4;  //制单人
                    oItem.HBillType = "3321";
                    oItem.HBillSubType = "3321";
                    //oItem.HBillNo = "";    //单据号
                    //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --日期
                    oItem.HBillSubType = "3321";
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    //oItem.HEquipID = 0;    //设备ID(Gy_EquipMent)
                    //oItem.HPeriod = 0;
                    oItem.HCheckEmp = oItem.HEmpID;           //维修人(Gy_Employee)
                    //oItem.HDeptID = 0;        //维修部门(Gy_Department)
                    //oItem.HMainSourceInterID = oItem.HInterID;
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    oItem.HCheckEmp = oItem.HEmpID;
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
@@ -15450,19 +15627,8 @@
                    i++;
                    oItem.HEntryID = i;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItem.HCloseType = false;   //关闭类型
                    //oItem.HInspectInstruMentID =1;         //备注
                    //oItem.HRelationQty = 0;     //关联数量
                    //oItem.HBeginDate = DateTime.Now.ToString();     //关联数量
                    //oItem.HEndDate = DateTime.Now.AddYears(1).ToString();     //关联数量
                    //oItem.HHCalibrationStatus = "合格";     //关联数量
                    //oItemSub.HRelationMoney = 0;   //关联金额
                    //oItemSub.HRepairID = 0;       //维修项目
                    //oItemSub.HRepairExplanation ="";   //维修要求
                    //oItemSub.HManagerID = 0;   //负责人ID
                    //oItemSub.HMoney = 0;        //维修费用
                    oBill.DetailColl.Add(oItem);
                }
@@ -15472,7 +15638,6 @@
                bool bResult;
                if (oBill.omodel.HInterID == 0)
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
@@ -15484,7 +15649,6 @@
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }