1
duhe
2025-03-31 9b4915b7b3669ffe80774740bd06c547ece49494
WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs
@@ -78,6 +78,43 @@
        }
        #endregion
        #region 器具维修派工单 编辑查询
        [Route("Sc_MouldRepairSendWorkBill/Sc_MouldRepairSendWorkBill_Edit")]
        [HttpGet]
        public object Sc_MouldRepairSendWorkBill_Edit(string linterid, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("select * from  h_v_Sc_MouldRepairSendWorkBill_Edit where 1=1 and hmainid=" + linterid + "order by hmainid desc ", "h_v_Sc_MouldRepairSendWorkBill_Edit");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 器具维修派工单查询
        [Route("Sc_MouldRepairSendWorkBill/GetMouldRepairSendWorkBillListPage")]
        [HttpGet]
@@ -185,6 +222,16 @@
                if (OperationType == 1)//新增
                {
                    //保存前控制
                    objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 1);
                    if (objJsonResult.count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = objJsonResult.Message;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //主表
                    oCN.RunProc("Insert Into Sc_MouldRepairSendWorkBill   " +
                 "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
@@ -205,6 +252,16 @@
                }
                else if (OperationType == 3)
                {
                    //保存前控制
                    objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 2);
                    if (objJsonResult.count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = objJsonResult.Message;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //修改
                    oCN.RunProc("UpDate Sc_MouldRepairSendWorkBill set  " +
                " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值===============
@@ -212,7 +269,7 @@
                ",HYear='" + omodel.HYear.ToString() + "'" +
                ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
                ",HRemark='" + omodel.HRemark + "'" +
                ",HUpDater='" + omodel.HUpDater + "'" +
                ",HUpDater='" + omodel.HMaker + "'" +
                ",HUpDateDate=getdate()" +
                    //========================================
                ",HMouldID=" + omodel.HMouldID.ToString() +
@@ -242,7 +299,7 @@
                    oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "'");
                }
                //保存子表
                objJsonResult = AddBillSub(msg3);
                objJsonResult = AddBillSub(msg3, OperationType);
                if (objJsonResult.code == "0")
                {
                    objJsonResult.code = "0";
@@ -268,7 +325,7 @@
            }
        }
        public json AddBillSub(string msg3)
        public json AddBillSub(string msg3,Int64 OperationType)
        {
            DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_MouldRepairWorkBillSub>>(msg3);
            int i = 1;
@@ -286,6 +343,32 @@
                   ") ");
                i++;
            }
            if (OperationType == 1)//新增
            {
                //保存后控制
                objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 1);
                if (objJsonResult.count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            else
            {
                //保存后控制
                objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 2);
                if (objJsonResult.count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = objJsonResult.Message;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            objJsonResult.code = "1";
            objJsonResult.count = 1;
@@ -293,6 +376,70 @@
            objJsonResult.data = null;
            return objJsonResult;
        }
        #region 器具维修派工单 保存前、保存后控制
        //保存前控制
        public json BeforeSave_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType)
        {
            DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "',''," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_BeforeSaveCtrl");
            if (BeforeSave == null || BeforeSave.Tables[0].Rows.Count == 0)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存前判断失败!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            else if (DBUtility.ClsPub.isLong(BeforeSave.Tables[0].Rows[0]["HBack"]) == 1)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;  //失败!
                objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
                objJsonResult.data = null;
                return objJsonResult;
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 1;  //成功!
                objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //保存后控制
        public json AfterSave_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType)
        {
            DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_AfterSaveCtrl");
            if (AfterSave == null || AfterSave.Tables[0].Rows.Count == 0)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存后判断失败!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            else if (DBUtility.ClsPub.isLong(AfterSave.Tables[0].Rows[0]["HBack"]) == 1)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;  //失败!
                objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
                objJsonResult.data = null;
                return objJsonResult;
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 1;  //成功!
                objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
@@ -323,7 +470,31 @@
                    return objJsonResult;
                }
                if (oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
                //删除前控制=========================================
                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeDelCtrl");
                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;
                }
                //==================================================================================
                bool IsDete = oBill.DeleteBill(HInterID, oBill.omodel.HBillNo, "h_p_Sc_MouldRepairSendWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -333,6 +504,7 @@
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败";
@@ -443,9 +615,35 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataSet ds2;
                //审核提交
                if (IsAudit == 0)
                {
                    //审核前控制=========================================
                    string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'";
                    ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl");
                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    if (CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "1";
@@ -467,6 +665,28 @@
                //反审核提交
                if (IsAudit == 1)
                {
                    //反审核前控制=========================================
                    string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'";
                    ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl");
                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //===========================================================
                    if (AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "1";
@@ -504,6 +724,34 @@
                string HChecker = DBUtility.ClsPub.CurUserName;//用户名
                oCN.BeginTran();//打开事务
                oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='" + HChecker + "',HCheckDate='" + DateTime.Now + "',HBillStatus=2 where HInterID='" + lngBillKey + "'");
                //审核后控制=========================================
                DataSet ds2;
                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl " + lngBillKey + ",'','" + HChecker + "'";
                ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl");
                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核失败!原因:审核后判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    sReturn = "审核失败!原因:审核后判断失败,请与网络管理人员联系";
                    return false;
                }
                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.data = null;
                    oCN.RollBack();
                    sReturn = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
                    return false;
                }
                //==================================================================================
                oCN.Commit();//关闭事务
                sReturn = "审核单据成功!";
                return true;
@@ -522,6 +770,33 @@
                string HChecker = DBUtility.ClsPub.CurUserName;//用户名
                oCN.BeginTran();//打开事务
                oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID='" + lngBillKey + "'");
                //反审核后控制=========================================
                DataSet ds2;
                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl " + lngBillKey + ",'','" + HChecker + "'";
                ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl");
                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核失败!原因:反审核后判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    sReturn = "审核失败!原因:反审核后判断失败,请与网络管理人员联系";
                    return false;
                }
                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.data = null;
                    oCN.RollBack();
                    sReturn = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
                    return false;
                }
                //==================================================================================
                oCN.Commit();//关闭事务
                sReturn = "反审核单据成功!";
                return true;
@@ -533,5 +808,146 @@
            }
        }
        #endregion
        #region 器具维修派工单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldRepairSendWorkBill/CloseSc_MouldRepairSendWorkBill")]
        [HttpGet]
        public object CloseSc_MouldRepairSendWorkBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sc_MouldRepairSendWorkBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsSc_ICMOBill oBill = new DAL.ClsSc_ICMOBill();           //实例化单据操作类,用于进行相关操作
                oBill.MvarItemKey = "Sc_MouldRepairSendWorkBill";
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    string sql = "";
                    //关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl " + HInterID + ",' ','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl");
                    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;
                    }
                    //关闭前控制===============================================End===================================================================
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, "", "h_p_Sc_MouldRepairSendWorkBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        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;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    string sql = "";
                    //反关闭前控制===============================================Begin===================================================================
                    sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl " + HInterID + ",'','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl");
                    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;
                    }
                    //反关闭前控制===============================================End===================================================================
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey,"", "h_p_Sc_MouldRepairSendWorkBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        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;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}