ch
2022-10-20 e79ef1f195754b2afdc8e1e149d64774c7757ad9
WebAPI/Controllers/LMESController.cs
@@ -32,13 +32,13 @@
                {
                    ds = oCN.RunProcReturn("select * from h_v_MES_StationInBillList", "h_v_MES_StationInBillList");
                }
                else
                else
                {
                    string sql1 = "select * from h_v_MES_StationInBillList where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_MES_StationInBillList");
                }
            }
            catch (Exception e)
            {
@@ -54,23 +54,23 @@
        /// </summary>
        [Route("LEMS/MES_Sc_ProcessExchangeBillQuery_Json")]
        [HttpGet]
        public object MES_Sc_ProcessExchangeBillList_Json(string sWhere,string user)
        public object MES_Sc_ProcessExchangeBillList_Json(string sWhere, string user)
        {
            DataSet ds;
            try
            {
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查询权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "无查询权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 " + sWhere+ " order by hmainid desc ", "h_v_Sc_ProcessExchangeBillQuery");
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeBillQuery");
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
@@ -114,7 +114,7 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = "select * from h_v_Sc_ProcessExchangeBillQuerySub where hmainid = ";
                string sql1 = sql + sWhere;
                ds = oCN.RunProcReturn(sql1, "h_v_Sc_ProcessExchangeBillQuerySub");
                ds = oCN.RunProcReturn(sql1 + " order by cast(工序号 as int)", "h_v_Sc_ProcessExchangeBillQuerySub");
            }
            catch (Exception e)
            {
@@ -126,6 +126,162 @@
            }
            return GetObjectJson(ds);
        }
        #region 工序流转卡(下达)
        /// <summary>
        /// 返回工序流转卡(下达)列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("LEMS/MES_Sc_ProcessExchangeIssueBillList_Json")]
        [HttpGet]
        public object MES_Sc_ProcessExchangeIssueBillList_Json(string sWhere, string user)
        {
            DataSet ds;
            try
            {
                ////判断是否有查询权限
                //if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "无查询权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeIssueBillQuery where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeIssueBillQuery");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 工序流转卡下达
        /// </summary>
        /// <returns></returns>
        [Route("LEMS/MES_Sc_ProcessExchangeIssue")]
        [HttpGet]
        public object MES_Sc_ProcessExchangeIssue(string HGroupID, string HSourceID, string HSourceSub1ID, string HSourceSub2ID, string HSourceSub3ID, string HEntryId)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn($"exec REALESE_Sc_ProcessExchangeIssue '{HGroupID}','{HSourceID}','{HSourceSub1ID}','{HSourceSub2ID}','{HSourceSub3ID}','{HEntryId}' ", "REALESE_Sc_ProcessExchangeIssue");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 工序流转卡指派日期
        /// </summary>
        /// <returns></returns>
        [Route("LEMS/MES_Sc_ProcessExchangePlanDate")]
        [HttpGet]
        public object MES_Sc_ProcessExchangePlanDate(string HPlanBeginDate, string HPlanEndDate, string HEntryId)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = string.Format(@"
update Sc_ProcessExchangeBillSub set
HPlanBeginDate = '{0}',
HPlanEndDate = '{1}'
where cast(HInterID as varchar(20))  +'-'+  cast(HEntryID as varchar(20)) in
(
 select * from fn_Split('{2}',',')
)", HPlanBeginDate, HPlanEndDate, HEntryId);
                oCN.RunProc(sql);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 工序流转卡反下达
        /// </summary>
        /// <returns></returns>
        [Route("LEMS/MES_Sc_ProcessExchangeCancelIssue")]
        [HttpGet]
        public object MES_Sc_ProcessExchangeCancelIssue(string HEntryId)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql = string.Empty;
                //删除生产状态表临时表数据
                sql = string.Format(@"
delete from Sc_ICMOBillStatus_Tmp
where
cast(HSOURCEINTERID as varchar(20))  +'-'+  cast(HSOURCEENTRYID as varchar(20)) in
(
select * from fn_Split('{0}',',')
)", HEntryId);
                oCN.RunProc(sql);
                //更改订单状态
                sql = string.Format(@"
update Sc_ProcessExchangeBillSub set
HGroupID=0, --班组
HSourceID=0, --生产资源
HIssue = 0 --下达状态
where cast(HInterID as varchar(20))  +'-'+  cast(HEntryID as varchar(20)) in
(
select * from fn_Split('{0}',',')
)", HEntryId);
                oCN.RunProc(sql);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "操作成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 返回工序出站汇报单列表
@@ -201,7 +357,7 @@
        /// </summary>
        [Route("LEMS/MES_Gy_RoutingBillList_Json")]
        [HttpGet]
        public object MES_Gy_RoutingBillList_Json(string sWhere,string user)
        public object MES_Gy_RoutingBillList_Json(string sWhere, string user)
        {
            DataSet ds;
            try
@@ -219,12 +375,12 @@
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList order by hmainid desc", "h_v_Gy_RoutingBillList");
                    ds = oCN.RunProcReturn("select top 1000 * from h_v_Gy_RoutingBillList order by hmainid desc", "h_v_Gy_RoutingBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_Gy_RoutingBillList where 1 = 1 ";
                    string sql = sql1 + sWhere+ " order by hmainid desc";
                    string sql1 = "select  top 1000 * from h_v_Gy_RoutingBillList where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)";
                    ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList");
                }
            }
@@ -248,7 +404,7 @@
        /// <returns></returns>
        [Route("LEMS/DeltetGy_RoutingBillSub")]
        [HttpGet]
        public object DeltetGy_RoutingBillSub(Int64 lngBillKey,string user)
        public object DeltetGy_RoutingBillSub(Int64 lngBillKey, string user)
        {
            DataSet ds;
            string ModRightNameCheck = "Gy_RoutingBill_Drop";
@@ -322,6 +478,49 @@
        }
        #endregion
        #region 工艺路线基础列表
        /// <summary>
        /// 返回工艺路线列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("LEMS/Gy_RoutingBillList")]
        [HttpGet]
        public object Gy_RoutingBillList(string sWhere, string user)
        {
            DataSet ds;
            try
            {
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql1 = "select * from h_v_Gy_RoutingBillList_Base where 1 = 1 ";
                string sql = sql1 + sWhere + " order by hmainid desc";
                ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList_Base");
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
            return GetObjectJson(ds);
        }
        #endregion
        #endregion
        /// <summary>
@@ -331,7 +530,7 @@
        /// </summary>
        [Route("LEMS/MES_IF_ICMOBillList_Json")]
        [HttpGet]
        public object MES_IF_ICMOBillList_Json(string sWhere,string user)
        public object MES_IF_ICMOBillList_Json(string sWhere, string user)
        {
            DataSet ds;
            try
@@ -346,7 +545,7 @@
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1 " + sWhere + " order by hmainid desc", "h_v_IF_ICMOBillList");
                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1 " + sWhere + " order by 单据号 desc", "h_v_IF_ICMOBillList");
            }
            catch (Exception e)
            {
@@ -698,7 +897,7 @@
        /// </summary>
        [Route("LEMS/Update_Gy_BarCodeBill_HQty")]
        [HttpGet]
        public object Update_Gy_BarCodeBill_HQty(string HBarCode,string HQty)
        public object Update_Gy_BarCodeBill_HQty(string HBarCode, string HQty)
        {
            DataSet ds;
            try
@@ -776,7 +975,7 @@
                    {
                        ds = oCN.RunProcReturn("exec h_p_Save_KF_PonderationBillMain_TempToSc_PackUnionBillMain '" + HBillNo + "',''", "h_p_Save_KF_PonderationBillMain_TempToSc_PackUnionBillMain");
                    }
                    else
                    else
                    {
                        ds = oCN.RunProcReturn("exec h_p_Save_KF_PonderationBillMain_TempToSc_PackUnionBillMain '" + HBillNo + "','" + HRemark + "'", "h_p_Save_KF_PonderationBillMain_TempToSc_PackUnionBillMain");
                    }
@@ -1220,6 +1419,6 @@
        }
    }
}