zrg
2024-06-25 7a49829b614767de98100810d0c787e7130c1624
WebAPI/Controllers/CJGL/Cj_StationInBillController.cs
@@ -115,8 +115,8 @@
                string HBillNo = list[0].HBillNo;//递入type得到的单据号
                int HBillStatus = 0;
                string HMaker = user;//制单人
                int HYear = 2021;
                double HPeriod = 1;
                int HYear = DateTime.Now.Year;
                double HPeriod = DateTime.Now.Month;
                string HRemark = list[0].HRemark;//备注
                long HICMOInterID = list[0].HICMOInterID;//任务单ID
                string HICMOBillNo = list[0].HICMOBillNo;//任务单
@@ -318,34 +318,34 @@
                    return objJsonResult;
                }
                
                ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl");
                if (ds == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows.Count == 0)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "判断数量失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl");
                //if (ds == null)
                //{
                //    oCN.RollBack();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "判断数量失败!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //if (ds.Tables[0].Rows.Count == 0)
                //{
                //    oCN.RollBack();
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "判断数量失败!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                //{
                //    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("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID + ",1");
                //判断是否是 首道工序
                ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a  " +
@@ -455,6 +455,63 @@
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序进站接收单流水号回车 系统参数判断是否绑定配件清单
        [Route("Cj_StationInBill/MES_StationInBillSubBindSource")]
        [HttpGet]
        public object MES_StationInBillSubBindSource(string HInterID, string HProcExchInterID,string HProcExchEntryID)
        {
            try
            {
                //如果系统参数启用了 进站单绑定配件清单则 从生产用料清单中获取工序BOM写入 临时表,并加载表格
                Pub_Class.ClsXt_SystemParameter oParam = new ClsXt_SystemParameter();
                string sIsBingLine = oParam.GetSingleSystemParameter("MES_StationInBill_LineBindCtl", ref DBUtility.ClsPub.sExeReturnInfo);
                if (sIsBingLine.Trim() == "Y")
                {
                    oCN.RunProc("exec h_p_MES_StationInBillSubBindSource_Insert " + HProcExchInterID.ToString() + " , " + HProcExchEntryID.ToString() + "," + HInterID.ToString() + " ");
                    ds = oCN.RunProcReturn($@"select * from
(
 select
a.HICMOInterID,a.HICMOEntryID,b.HProcID
from Sc_ProcessExchangeBillMain a with(nolock)
inner join Sc_ProcessExchangeBillSub b with(nolock)  on a.HInterID=b.HinterID
Where a.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
) a
inner join (
select a.HICMOInterID,a.HICMOEntryID, b.HProcID
from Sc_PPBomBillMain a with(nolock)
inner join Sc_PPBomBillSub b with(nolock)  on a.HInterID=b.HInterID
Where b.HKeyMaterID_Line<>0
)b on a.HICMOInterID=b.HICMOInterID and a.HICMOEntryID=b.HICMOEntryID and a.HProcID=b.HProcID", "Sc_ProcessExchangeBillMain");
                    if (ds.Tables[0].Rows.Count > 0) {
                        objJsonResult.Message = "需要绑定配件!";
                    }
                    else
                    {
                        objJsonResult.Message = "不需要绑定配件!";
                    }
                }
                else {
                    objJsonResult.Message = "不需要绑定配件!";
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.data =null;
                return objJsonResult;
            }
            catch (Exception e)
@@ -815,8 +872,31 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //审核前控制
                string HBillNo = oBill.omodel.HBillNo;
                string sql = "exec h_p_Sc_StationInBill_BeforeCheckCtrl " + HInterID + ",'" + HBillNo + "','" + CurUserName + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationInBill_BeforeCheckCtrl");
                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 (Cj_StationInBillCheckBill(HInterID,CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
                if (Cj_StationInBillCheckBill(HInterID, HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -845,7 +925,7 @@
        }
        //审核
        public bool Cj_StationInBillCheckBill(Int64 lngBillKey, string CurUserName, ref string sReturn)
        public bool Cj_StationInBillCheckBill(Int64 lngBillKey,string HBillNo, string CurUserName, ref string sReturn)
        {
            try
            {
@@ -873,6 +953,23 @@
                else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "是")
                {
                }
                //审核后控制
                string sql = "exec h_p_Sc_StationInBill_AfterCheckCtrl " + lngBillKey + ",'" + HBillNo + "','" + CurUserName + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationInBill_AfterCheckCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "审核过程中出错,请与网络管理人员联系";
                    oCN.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    oCN.RollBack();
                    return false;
                }
                sReturn = sReturn + " 审核功能!";
                oCN.Commit();
                return true;
@@ -949,8 +1046,31 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //反审核前控制
                string HBillNo = oBill.omodel.HBillNo;
                string sql = "exec h_p_Sc_StationInBill_BeforeUnCheckCtrl " + HInterID + ",'" + HBillNo + "','" + CurUserName + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationInBill_BeforeUnCheckCtrl");
                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 (Cj_StationInBillAbandonCheckBill(HInterID, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
                if (Cj_StationInBillAbandonCheckBill(HInterID, HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -978,7 +1098,7 @@
        }
        //反审核
        public bool Cj_StationInBillAbandonCheckBill(Int64 lngBillKey, string CurUserName, ref string sReturn)
        public bool Cj_StationInBillAbandonCheckBill(Int64 lngBillKey,string HBillNo, string CurUserName, ref string sReturn)
        {
            if (Cj_StationInBillisUse(lngBillKey, ref sReturn))
            {
@@ -1011,6 +1131,23 @@
                else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "是")
                {
                }
                //反审核后控制
                string sql = "exec h_p_Sc_StationInBill_AfterUnCheckCtrl " + lngBillKey + ",'" + HBillNo + "','" + CurUserName + "'";
                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationInBill_AfterUnCheckCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "反审核过程中出错,请与网络管理人员联系";
                    oCN.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    oCN.RollBack();
                    return false;
                }
                sReturn = sReturn + "反审核功能!";
                oCN.Commit();
                return true;
@@ -1306,8 +1443,31 @@
                        return objJsonResult;
                    }
                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                    //删除前控制=========================================
                    string HBillNo = oBill.omodel.HBillNo;
                    string sql1 = "exec h_p_Sc_StationInBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + HDeleteMan + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_StationInBill_BeforeDelCtrl");
                    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;
                    }
                    //==================================================================================
                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, HBillNo, "h_p_Sc_StationInBill_AfterDelCtrl", HDeleteMan, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;