YL
2021-09-01 005a6ed14ccad1aeaa30d6738a6b651e63ed483d
WebAPI/Controllers/Éú²ú¹ÜÀí/ÖÊÁ¿»ã±¨µ¥/Sc_QualityReportBillController.cs
@@ -16,8 +16,10 @@
    public class Sc_QualityReportBillController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        private json objJsonResult = new json();
        private json objJsonResultReturn = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        DataSet ds;
        #region è¿”回生产质量汇报单列表
@@ -286,26 +288,117 @@
        #endregion
        #region å®¡æ ¸
        public bool set_CheckBill(long HInterID, ref string sReturn)
        public object set_CheckBill(long HInterID,string HChecker, ref string sReturn)
        {
            SQLHelper.ClsCN oCN1 = new SQLHelper.ClsCN();
            try
            {
                oCN.BeginTran();
                ds = oCN.RunProcReturn("exec Sc_ICMOBillQualityStatus_AutoCheck", "Sc_ICMOBillQualityStatus_AutoCheck");
                if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                oCN1.BeginTran();
                //审核权限
                if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Check", 1, true, HChecker))
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    oCN.RollBack();
                    return false;
                    oCN1.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "您没有权限,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                sReturn = "审核成功!";
                oCN.Commit();
                //
                if (HInterID == 0)
                {
                    oCN1.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据ID为0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsSc_QualityReportBill oBill = new DAL.ClsSc_QualityReportBill();
                //查看是否已审核,关闭,作废
                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    if (oBill.omodel.HChecker.Trim() != "")
                    {
                        oCN1.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HCloseMan.Trim() != "")
                    {
                        oCN1.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已关闭!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        oCN1.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    oCN1.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //审核
                if (CheckBill(HInterID, HChecker, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                {
                    oCN1.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    oCN1.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                oCN1.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败!原因:" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //审核SQL
        public bool CheckBill(Int64 HInterID,string HChecker, ref string sReturn)
        {
            try
            {
                oCN.RunProc(" Update Sc_QualityReportBillMain set HChecker='" + HChecker + "',HCheckDate=GETDATE() Where HInterID=" + HInterID.ToString());
                sReturn = "";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCN.RollBack();
                throw (e);
            }
        }
@@ -431,15 +524,16 @@
        #region æäº¤ä¿å­˜ï¼Œå­˜ä¸»å­è¡¨åŠæ˜Žç»†è¡¨
        [Route("Sc_QualityReportBill/set_SaveBill")]
        [HttpGet]
        public object set_SaveBill(long HInterID)
        public object set_SaveBill(long HInterID,string HChecker)
        {
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                bool bResult2 = false;
                oCN.BeginTran();
                //保存
                oCN.RunProc("exec h_p_save_Sc_QualityReportBill " + HInterID);
                //判断是否允许保存
                //判断是否允许保存,不允许则回滚
                ds = oCN.RunProcReturn("exec h_p_JIT_ICMOBillQualityStatus_SaveCtrl", "h_p_JIT_ICMOBillQualityStatus_SaveCtrl");
                if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
                {
@@ -450,27 +544,46 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //是否审核
                bResult2 = set_CheckBill(HInterID, ref ClsPub.sExeReturnInfo);
                //是否审核
                if (bResult2 == true)
                oCN.Commit();
                //获取自动审核参数
                string sReturn = "";
                if (oSystemParameter.ShowBill(ref sReturn) == true)
                {
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "单据保存成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                    if (oSystemParameter.omodel.Sc_ICMOBillQualityStatus_AutoCheck == "Y") //系统参数  è‡ªåŠ¨å®¡æ ¸
                    {
                        //审核
                        objJsonResultReturn = (json)set_CheckBill(HInterID, HChecker, ref ClsPub.sExeReturnInfo);
                        if (objJsonResultReturn.code == "1")
                        {
                            objJsonResult.code = "1";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "单据存盘完毕!审核成功!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            objJsonResult.code = "1";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "单据存盘完毕!自动审核失败,原因:" + objJsonResultReturn.Message;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "单据存盘完毕!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据存盘完毕!自动审核失败,原因:" + ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "单据存盘完毕!获取自动审核参数失败!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {