zgq
2021-08-23 76f4f1a8019f67277a5c5a531bc1259363fccb75
新增反审核接口-进站接收
1个文件已修改
133 ■■■■■ 已修改文件
WebAPI/Controllers/CJGL/Cj_StationInBillController.cs 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/CJGL/Cj_StationInBillController.cs
@@ -584,6 +584,139 @@
        }
        #endregion
        #region 反审核
        [Route("Cj_StationInBill/set_AbandonCheck")]
        [HttpGet]
        public object set_AbandonCheck(int HInterID, string CurUserName)
        {
            try
            {
                if (HInterID == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据ID为0,不能反审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsSc_StationInBill oBill = new DAL.ClsSc_StationInBill();
                //查看是否已审核,关闭,作废
                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    if (oBill.omodel.HChecker.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 (Cj_StationInBillAbandonCheckBill(HInterID, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //反审核
        public bool Cj_StationInBillAbandonCheckBill(Int64 lngBillKey, string CurUserName, ref string sReturn)
        {
            if (Cj_StationInBillisUse(lngBillKey, ref sReturn))
            {
                return false;
            }
            try
            {
                string HChecker = CurUserName;
                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                oCN.BeginTran();
                ds = oCN.RunProcReturn("Select * from Sc_StationInBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_StationInBillMain");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                oCN.RunProc(" Update Sc_StationInBillMain set HChecker='',HCheckDate=null Where HInterID=" + lngBillKey.ToString());
                oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Check_In " + lngBillKey.ToString() + ",-1");
                //判断是否是 首道工序
                DataSet ds1;
                ds1 = oCN.RunProcReturn("select HLastProc,HFstProc " +
                    " from Sc_ProcessExchangeBillMain a " +
                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID " +
                    " Where a.HInterID=(Select HProcExchInterID from Sc_StationInBillMain Where HInterID=55) " +
                    " and b.HEntryID=(Select HProcExchEntryID from Sc_StationInBillMain Where HInterID=55)", "Sc_ProcessExchangeBillMain");
                if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
                {
                }
                else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "是")
                {
                }
                sReturn = sReturn + "反审核功能!";
                oCN.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCN.RollBack();
                return false; ;
            }
        }
        //是否被关联
        public bool Cj_StationInBillisUse(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                //Ds = oCN.RunProcReturn("Select HinterID from " + MvarItemKeySub + "  Where HInterID=" + lngBillKey.ToString() + " and isnull(HRelationQty,0)<>0 ", MvarItemKey);
                //if (Ds.Tables[0].Rows.Count != 0)
                //{
                //    sReturn = "单据已被关联,不能操作!";
                //    return true;
                //}
                sReturn = "";
                return false;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        #endregion
        //
    }