zrg
2025-04-08 d54613ce0b6960dafcbd28454172f21a2d0bb6d1
WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs
@@ -132,7 +132,7 @@
        [HttpGet]
        public object Delete_EquipFile(string HItemID, string user)
        {
            if (!DBUtility.ClsPub.Security_Log("Gy_EquipFile_Delete", 1, false, user))
            if (!DBUtility.ClsPub.Security_Log("Gy_EquipFileBill_Delete", 1, false, user))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
@@ -166,9 +166,57 @@
                    return objJsonResult;
                }
                //删除前控制=========================================
                ds = oCN.RunProcReturn("Exec h_p_Gy_Maintain_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_Maintain_BeforeDelCtrl");
                if (ds == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                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"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.RunProc("Delete From Gy_EquipFileBillMain  where HInterID=" + lngBillKey);
                oCN.RunProc("Delete From Gy_EquipFileBillSub_MaintainRule  where HInterID=" + lngBillKey);
                oCN.RunProc("Delete From Gy_EquipFileBillSub_DotCheckRule  where HInterID=" + lngBillKey);
                //删除后控制=========================================
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_Maintain_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_Maintain_AfterDelCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除后判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.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"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -363,6 +411,8 @@
                int HEquipDotCheckRuleInterID = list[0].HEquipDotCheckRuleInterID;
                int HEquipMaintainRuleInterID = list[0].HEquipMaintainRuleInterID;
                int HSourceID = list[0].HSourceID;
                int HCREATEORGID = list[0].HCREATEORGID;
                int HUSEORGID = list[0].HUSEORGID;
                if (!DBUtility.ClsPub.AllowNumber(HEquipFileNumber))
                {
@@ -386,9 +436,10 @@
                oCN.BeginTran();
                //保存前控制=========================================
                string HBillNote = "";
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBillMain_BeforeSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBillMain_BeforeSaveCtrl");
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_BeforeSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBill_BeforeSaveCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
@@ -398,6 +449,7 @@
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
@@ -410,19 +462,20 @@
                   " (HInterID,hbillno,HEquipFileNumber,HEquipFileNo,HName,HModel,HModel2,HMaterID,HUnitID,HOutComDate" +
                   ",HOutComNo,HDeptID,HUseEmpID,HRepairEmpID,HAddress,HSetupDate,HStartupDate,HStatus," +
                    "HEquipFileTypeID,HProNum,HBarCode,HWorkArea,HLogo,HSellSupID,HMakeSupID,hbilltype,HDate,HYear,HMaker,HMakeDate,HEquipMaintainRuleInterID,HEquipDotCheckRuleInterID," +
                    "HSourceID,HMainSourceFlag,HMacAddress,HMainSourceID,HIPAddress,HLinkNETMode,HCollectMode,HCollectClass) " +
                    "HSourceID,HMainSourceFlag,HMacAddress,HMainSourceID,HIPAddress,HLinkNETMode,HCollectMode,HCollectClass,HCREATEORGID,HUSEORGID) " +
                   " Values("+ HInterID+",'" + hbillno + "','" + HEquipFileNumber + "','" + HEquipFileNo + "','" + HName + "','" + HModel + "','" + HModel2 + "'," + HMaterID + "," + HUnitID +
                   ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HUseEmpID + "," + HRepairEmpID + ",'" + HAddress +
                   "','" + HSetupDate + "','" + HStartupDate + "','" + HStatus + "'," + HEquipFileTypeID + ",'" + HProNum +
                   "','" + HBarCode + "','" + HWorkArea + "','" + HLogo + "'," + HSellSupID + "," + HMakeSupID + ",'3308','" + HDate + "','" + HYear + "','" + HMaker + "',GETDATE(),'" + HEquipMaintainRuleInterID + "','" + HEquipDotCheckRuleInterID +"'" +
                   "," + HSourceID + ",'" + HMainSourceFlag + "','" + HMacAddress + "','" + HMainSourceID + "','" + HIPAddress + "','" + HLinkNETMode + "','" + HCollectMode + "','" + HCollectClass + "')", ref DBUtility.ClsPub.sExeReturnInfo);
                   "," + HSourceID + ",'" + HMainSourceFlag + "','" + HMacAddress + "','" + HMainSourceID + "','" + HIPAddress + "','" + HLinkNETMode + "','" + HCollectMode + "','" + HCollectClass + "',"+ HCREATEORGID + ","+ HUSEORGID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                //修改上级为非末级代码
                objJsonResult = AddBillSub(msg3, msg4, HInterID, hbillno, 1);
                //保存后控制=========================================
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBillMain_AfterSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBillMain_AfterSaveCtrl");
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBill_AfterSaveCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
@@ -431,7 +484,8 @@
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
@@ -489,6 +543,7 @@
                long HInterID = list[0].HInterID;
                string HEquipFileNumber = list[0].HEquipFileNumber;
                string hbillno = list[0].HBillNo;
                string HEquipFileNo = list[0].HEquipFileNo;         //   varchar(50)   //设备编码(唯一)
                string HName = list[0].HName;                //    √   varchar(100)        //设备名称
                string HModel = list[0].HModel;               //   √    varchar(100)        //设备规格
@@ -523,6 +578,7 @@
                int HEquipDotCheckRuleInterID = list[0].HEquipDotCheckRuleInterID;
                int HEquipMaintainRuleInterID = list[0].HEquipMaintainRuleInterID;
                int HSourceID = list[0].HSourceID;
                int HUSEORGID = list[0].HUSEORGID;
                if (!DBUtility.ClsPub.AllowNumber(HEquipFileNumber))
@@ -548,6 +604,31 @@
                //若MAINDI重复则重新获取
                oCN.BeginTran();
                //保存前控制=========================================
                string HBillNote = "";
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_BeforeSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBill_BeforeSaveCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                //主表
                oCN.RunProc("Update Gy_EquipFileBillMain set " +
                    " HEquipFileNumber='" + HEquipFileNumber + "'" +
@@ -573,6 +654,7 @@
                    ",HLogo='" + HLogo + "'" +
                    ",HSellSupID=" + HSellSupID +
                    ",HMakeSupID= " + HMakeSupID +
                    ",HUSEORGID= " + HUSEORGID +
                    ",HUpDater= '" + HUpDater + "'" +
                    ",HUpDateDate= GETDATE()" +
                    ",HEquipDotCheckRuleInterID='" + HEquipDotCheckRuleInterID + "'" +
@@ -590,6 +672,32 @@
                //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
                //
                objJsonResult = AddBillSub(msg3, msg4, HInterID, list[0].HBillNo, 2);
                //保存后控制=========================================
                ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + hbillno + "','" + HBillNote + "',1 ", "h_p_Gy_EquipFileBill_AfterSaveCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                //objJsonResult.data = null;
                return objJsonResult;
@@ -852,6 +960,28 @@
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //审核前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_BeforeDelCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_EquipFileBill_BeforeDelCtrl");
                    if (ds == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    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"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    if (!BillOld.CheckBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
@@ -860,9 +990,53 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_AfterDelCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_EquipFileBill_AfterDelCtrl");
                    if (ds2 == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核后判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.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"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                }
                else
                {
                    //反审核前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_BeforeUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_EquipFileBill_BeforeUnCheckCtrl");
                    if (ds == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    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"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    if (BillOld.AbandonCheck(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
@@ -875,6 +1049,29 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反审核后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_EquipFileBill_AfterUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_EquipFileBill_AfterUnCheckCtrl");
                    if (ds2 == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核后判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.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"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                }
                oCN.Commit();//提交事务
@@ -971,6 +1168,80 @@
        }
        #endregion
        #region 设备档案作废/反作废功能
        [Route("Gy_EquipFileBill/DeleteGy_EquipFileBill")]
        [HttpGet]
        public object DeleteGy_EquipFileBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Gy_EquipFileBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                oCN.BeginTran();//开始事务
                //Type 1 作废  2  反作废
                if (Type == 1)
                {
                    if (!BillOld.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    if (!BillOld.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 设备档案列表 树状图 设备分类查询
        public class TreeModel
        {