1
wtt
4 天以前 35626914ad4ec78ff71bef1c2d52a9d04ee67954
WebAPI/Controllers/CJGL/Sc_ProcExchSendWorkBillController.cs
@@ -19,13 +19,23 @@
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        DataSet ds;
        #region 工序派工单列表
        #region 工序流转卡派工单列表
        [Route("Sc_ProcExchSendWorkBill/Sc_ProcExchSendWorkBillList")]
        [HttpGet]
        public object Sc_ProcExchSendWorkBillList(string sWhere, string user)
        {
            try
            {
                //判断是否有权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchSendWorkBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查看!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> columnNameList = new List<object>();               
                string sql1 = "select * from h_v_Sc_ProcExchSendWorkBillList where 1 = 1  ";
@@ -59,7 +69,47 @@
        }
        #endregion
        #region 工序派工单列表(职员查看自己任务)
        #region 工序流转卡派工单编辑回显
        [Route("Sc_ProcExchSendWorkBill/Sc_ProcExchSendWorkBillEdit")]
        [HttpGet]
        public object Sc_ProcExchSendWorkBillEdit(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = "select * from h_v_Sc_ProcExchSendWorkBillEdit where 1 = 1  ";
                string sql = sql1 + sWhere + " order by hmainid desc";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcExchSendWorkBillEdit");
                //添加列名
                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.list = columnNameList;
                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("Sc_ProcExchSendWorkBill/Sc_ProcExchSendWorkBillListByEmp")]
        [HttpGet]
        public object Sc_ProcExchSendWorkBillListByEmp(string sWhere, string user,int HEmpID)
@@ -98,6 +148,110 @@
        }
        #endregion
        #region 工序流转卡派工 删除(子表)用于取消派单
        [Route("Sc_ProcExchSendWorkBill/DelProcessSendWork_Sec")]
        [HttpGet]
        public object DelProcessSendWork_Sec(string HInterID, string HEntryID, string User)
        {
            try
            {
                ds = oCN.RunProcReturn("select a.* from Sc_ProcExchSendWorkBillMain a left join Sc_ProcExchSendWorkBillSub b on b.HInterID= a.HInterID where 1=1 and a.HInterID=" + HInterID, "Sc_ProcExchSendWorkBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "1"&& ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "当前单据不能删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //删除前控制=========================================
                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                    string sql1 = "exec h_p_Sc_ProcExchSendWorkBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + User + "'";
                    DataSet ds1 = oCN.RunProcReturn(sql1, "h_p_Sc_ProcExchSendWorkBill_BeforeDelCtrl");
                    if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.BeginTran();//开启事务
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        oCN.RunProc($"delete from Sc_ProcExchSendWorkBillMain where HInterID={HInterID}");
                    }
                    oCN.RunProc($"delete from Sc_ProcExchSendWorkBillSub where HInterID={HInterID} and HEntryID={HEntryID}");
                    //删除后控制=========================================
                    string sql2 = "exec h_p_Sc_ProcExchSendWorkBill_AfterDelCtrl " + HInterID + ",'" + HBillNo + "','" + User + "'";
                    DataSet ds2 = oCN.RunProcReturn(sql2, "h_p_Sc_ProcExchSendWorkBill_AfterDelCtrl");
                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.Commit();//结束事务
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "当前单据不存在,无法删除!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();//回滚事务
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 派工平台查询工序流转卡数据
        [Route("Sc_ProcExchSendWorkBill/Sc_ProcessExchangeHEmpList")]
        [HttpGet]
@@ -110,7 +264,7 @@
                List<object> columnNameList = new List<object>();
                //得到信息(委外标记为0时,流转标记为1时)
                //ds = oCN.RunProcReturn("select  * from h_v_Sc_ProcessExchangeBillList_Sec  where 下道流转工序<>'转' and 委外标记=0 and 流转标记=1  and 工序号='" + sProcNo + "' and 序列号='" + HSEQNumber + "'", "h_v_Sc_ProcessExchangeBillList_Sec");
                ds = oCN.RunProcReturn("select  * from h_v_Sc_ProcessExchangeArrangementHEmpList  where 1=1 " + sWhere, "h_v_Sc_ProcessExchangeArrangementHEmpList");
                ds = oCN.RunProcReturn("select Top 1000 * from h_v_Sc_ProcessExchangeArrangementHEmpList  where 1=1 " + sWhere, "h_v_Sc_ProcessExchangeArrangementHEmpList");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -166,9 +320,9 @@
        }
        #endregion
        #region 工序派工单 保存/编辑
        #region 工序流转卡派工单 保存/编辑
        /// <summary>
        /// 工序派工单 保存
        /// 工序流转卡派工单 保存
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
@@ -182,7 +336,17 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string msg5 = sArray[3].ToString();
            //判断是否有权限
            if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchSendWorkBill_Edit", 1, false, msg5))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无权限保存!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            string UserName = "";
            ListModels oListModels = new ListModels();
@@ -231,10 +395,6 @@
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = oItemSub.HSourceInterID;     // 源单主内码
                    oItemSub.HSourceEntryID = oItemSub.HSourceEntryID;   //源单子内码
                    oItemSub.HSourceBillNo = oItemSub.HSourceBillNo;  //源单单号
                    oItemSub.HSourceBillType = oItemSub.HSourceBillType; //源单类型
                    oItemSub.HRelationQty = 0;     //关联数量
            
                    oBill.DetailColl.Add(oItemSub);
@@ -280,13 +440,24 @@
        }
        #endregion
        //#region 工序派工单 删除
        #region 工序流转卡派工单 删除
        [Route("Sc_ProcExchSendWorkBill/DelProcessSendWork")]
        [HttpGet]
        public object DelProcessSendWork(string HInterID, string user)
        {
            Int64 lngBillKey = 0;
            lngBillKey = DBUtility.ClsPub.isLong(HInterID);
            //判断是否有权限
            if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchSendWorkBill_Delete", 1, false, user))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无权限删除!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            if (lngBillKey == 0)
            {
                objJsonResult.code = "0";
@@ -368,17 +539,17 @@
                return objJsonResult;
            }
        }
        //#endregion
        #endregion
        #region 工序派工单审核/反审核功能
        #region 工序流转卡派工单审核/反审核功能
        [Route("Sc_ProcExchSendWorkBill/CheckSc_ProcExchSendWorkBill")]
        [HttpGet]
        public object CheckSc_ProcExchSendWorkBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Check", 1, false, user))
                //判断是否有权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchSendWorkBill_Check", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -535,7 +706,7 @@
        }
        #endregion
        #region 工序派工单关闭/反关闭功能
        #region 工序流转卡派工单关闭/反关闭功能
        [Route("Sc_ProcExchSendWorkBill/CloseSc_ProcExchSendWorkBill")]
        [HttpGet]
        public object CloseSc_ProcExchSendWorkBill(string HInterID, int Type, string user)
@@ -543,7 +714,7 @@
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Close", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchSendWorkBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;