yxj
2025-03-18 f02c7cbe27d7da079f057b464e2b179f1dc17b08
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -2096,6 +2096,8 @@
                int HNowWHID = mainList[0].HNowWHID;
                int HNowSPID = mainList[0].HNowSPID;
                string HMouldUseStatus = mainList[0].HMouldUseStatus;
                int HCREATEORGID = mainList[0].HCREATEORGID;
                int HUSEORGID = mainList[0].HUSEORGID;
                //保存前控制=========================================
                string HBillNote = "";
@@ -2131,7 +2133,7 @@
                ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" +
                ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" +
                ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" +
                ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus) " +
                ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID) " +
                " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
                "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" +
@@ -2141,7 +2143,7 @@
                "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty +
                "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" +
                ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
                ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "') ");
                ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "',"+ HCREATEORGID + ","+ HUSEORGID + ") ");
                //子表
                oCN.RunProc("Insert into Gy_MouldFileSub " +
@@ -2292,8 +2294,32 @@
                int HNowWHID = mainList[0].HNowWHID;
                int HNowSPID = mainList[0].HNowSPID;
                string HMouldUseStatus = mainList[0].HMouldUseStatus;
                int HUSEORGID = mainList[0].HUSEORGID;
                //若MAINDI重复则重新获取
                oCN.BeginTran();
                //保存前控制=========================================
                string HBillNote = "";
                ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_BeforeSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_BeforeSaveCtrl");
                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]["HBackRemark"].ToString(); ;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                //主表
                oCN.RunProc("UpDate Gy_MouldFileMain set  " +
                " HBillNo='" + HBillNo + "'" +  //固定赋值===============
@@ -2314,6 +2340,7 @@
                ",HPICNo='" + HPICNo + "'" +
                ",HWorkMaterModel='" + HWorkMaterModel + "'" +
                ",HMaterID=" + HMaterID.ToString() +
                ",HUSEORGID=" + HUSEORGID.ToString() +
                ",HMaterNumber='" + HMaterNumber + "'" +
                ",HMouldClass='" + HMouldClass + "'" +
                ",HMouldType=" + HMouleTypeID.ToString() +
@@ -2360,6 +2387,29 @@
                oCN.RunProc("delete from Gy_MouldFileSub_MaintainRule where HInterID='" + HInterID + "'");
                oCN.RunProc("delete from Gy_MouldFileSub_DotCheckRule where HInterID='" + HInterID + "'");
                objJsonResult = AddBillSub(msg5, msg6, msg7, HInterID, HBillNo);
                //保存后控制=========================================
                ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_AfterSaveCtrl");
                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]["HBackRemark"].ToString(); ;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                objJsonResult.code = "1";
@@ -2546,8 +2596,56 @@
                }
                if (oBill.DeleteBill(hmainid, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    oCN.BeginTran();
                    //删除前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_BeforeDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_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_MouldFileSub_MaintainRule  where HInterID=" + hmainid);
                    oCN.RunProc("Delete From Gy_MouldFileSub_DotCheckRule  where HInterID=" + hmainid);
                    //删除后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_AfterDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_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();
                    //写入日志
                    ClsPub.Add_Log("", "删除项目,代码:" + oBill.omodel.HMouldNo + ",名称:" + oBill.omodel.HName, ClsPub.CurUserName);
                    //更新上级为 末级
@@ -2921,6 +3019,26 @@
                }
                if (IsAudit == 0) //审核提交
                {
                    //审核前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_BeforeCheckCtrl");
                    if (ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -2938,9 +3056,50 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_AfterCheckCtrl");
                    if (ds2 == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核后判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_BeforeUnCheckCtrl");
                    if (ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -2958,6 +3117,29 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反审核后控制=========================================
                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_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;
                    }
                    //=========================================================
                }
                return objJsonResult;
            }
@@ -2972,6 +3154,154 @@
        }
        #endregion
        #region 模具案关闭/反关闭功能
        [Route("Gy_Mould/CloseGy_Mould")]
        [HttpGet]
        public object CloseGy_Mould(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Gy_MouldFile_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;
                DAL.ClsGy_MouldFile oBill = new DAL.ClsGy_MouldFile();
                oCN.BeginTran();//开始事务
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    if (!oBill.CloseBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    if (!oBill.CancelClose(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 模具档案作废/反作废功能
        [Route("Gy_Mould/DeleteGy_Mould")]
        [HttpGet]
        public object DeleteGy_Mould(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Gy_MouldFile_Drop", 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;
                }
                DAL.ClsGy_MouldFile oBill = new DAL.ClsGy_MouldFile();
                ClsPub.CurUserName = user;
                oCN.BeginTran();//开始事务
                //Type 1 作废  2  反作废
                if (Type == 1)
                {
                    if (!oBill.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    if (!oBill.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 [模具档案批量生成]
        [Route("Gy_Mould/SaveBatchGen_MouldFile")]
        [HttpGet]