WebAPI/Controllers/LMESController.cs
@@ -104,6 +104,8 @@
                }
                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");
@@ -131,6 +133,92 @@
                return objJsonResult;
            }
        }
        #region 工序流转卡维护-查询
        /// <summary>
        /// 返回工序流转卡维护列表主表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("LEMS/Sc_ProcessExchangeBillList_Query")]
        [HttpGet]
        public object Sc_ProcessExchangeBillList_Query(string sWhere, string user, string HBillSubType)
        {
            DataSet ds;
            try
            {
                List<object> columnNameList = new List<object>();
                if (HBillSubType == "SUB")
                {
                    //判断是否有查询权限
                    if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_SubQuery", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "指引卡无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断是否有查询权限
                    if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "流转卡无查询权限!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //获取系统参数
                string Ret = "";
                if (oSystemParameter.ShowBill(ref Ret))
                {
                    //判断客户为龙山汽配
                    if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配")
                    {
                        //获取需要拼接的字符串
                        string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序派工单列表");
                        sWhere += sql_splice;
                    }
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillList_Query where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeBillList_Query");
                //添加列名
                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 = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序流转卡 下查
        /// <summary>
@@ -304,6 +392,243 @@
                return objJsonResult;
            }
        }
        #region 工序流转卡只显示工序数据
        [Route("LEMS/MES_ProcessExchangeBillList_PG")]
        [HttpGet]
        public object MES_ProcessExchangeBillList_PG(string sWhere, string user, int OperationType)
        {
            DataSet ds;
            try
            {
                List<object> columnNameList = new List<object>();
                //判断是否有查询权限
                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 (OperationType == 1)
                {
                    //获取系统参数
                    string Ret = "";
                    if (oSystemParameter.ShowBill(ref Ret))
                    {
                        //判断客户为杭州斯莫尔
                        if (oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔")
                        {
                            sWhere += "  ";
                        }
                        else
                        {
                            sWhere += "  ";
                        }
                    }
                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                    ds = oCN.RunProcReturn("select top 1000 * from h_v_Sc_ProcessExchangeArrangementList_PG where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeArrangementList_PG");
                }
                else
                {
                    //获取系统参数
                    string Ret = "";
                    if (oSystemParameter.ShowBill(ref Ret))
                    {
                        //判断客户为杭州斯莫尔
                        if (oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔")
                        {
                        }
                    }
                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                    ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeArrangementList_PG where 1 = 1 " + sWhere, "h_v_Sc_ProcessExchangeArrangementList_PG");
                }
                //添加列名
                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 = "异常!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 工序流转卡 派工(斯莫尔)
        [Route("LEMS/ProcessExchangeArrangement_Add_PG")]
        [HttpGet]
        public object ProcessExchangeArrangement_Add_PG(string HInterID_S, int HSourceID, long HOrgID, string user)
        {
            DataSet ds;
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                var HNum = HInterID_S.Split(',');
                for (int j = 0; j < HNum.Length; j++)
                {
                    long HInterID = long.Parse(HNum[j].Split('|')[0]);
                    long HEntryID = long.Parse(HNum[j].Split('|')[1]);
                    ds = oCN.RunProcReturn(@"select a.HMaterID,b.HProcID,a.HBillNo from Sc_ProcessExchangeBillMain a inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID
where a.HInterID=" + HInterID + " and b.HEntryID=" + HEntryID, "Sc_ProcessExchangeBillMain");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "查无此工序流转卡!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn(@"select * from Sc_ICMOBillStatus_Tmp where HSourceInterID='"+ HInterID + "'   and  HSourceEntryID='"+ HEntryID + "'", "Sc_ICMOBillStatus_Tmp");
                    if (ds.Tables[0].Rows.Count != 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "该工序已派单,不允许重复排单!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oCN.BeginTran();
                    oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=" + HSourceID + " where HInterID=" + HInterID + " and HEntryID=" + HEntryID);
                    oCN.RunProc("exec h_p_Sc_ICMOBillStatus_Tmp_PG " + HInterID + "," + HEntryID);
                    oCN.Commit();
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                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("LEMS/ProcessExchangeArrangementDel_PG")]
        [HttpGet]
        public object ProcessExchangeArrangementDel_PG(string HInterID_S, int HSourceID, string user)
        {
            DataSet ds;
            DataSet ds1;
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "流转卡无编辑权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                var HNum = HInterID_S.Split(',');
                oCN.BeginTran();
                for (int j = 0; j < HNum.Length; j++)
                {
                    long HInterID = long.Parse(HNum[j].Split('|')[0]);
                    long HEntryID = long.Parse(HNum[j].Split('|')[1]);
                    ds = oCN.RunProcReturn(@"select a.HMaterID,b.HProcID,a.HBillNo from Sc_ProcessExchangeBillMain a inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID
where a.HInterID=" + HInterID + " and b.HEntryID=" + HEntryID, "Sc_ProcessExchangeBillMain");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "查无此工序流转卡!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + "  and HSourceID=" + HSourceID, "Sc_ICMOBillStatus_Tmp");
                    if (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]["HICMOStatus"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "流转卡对应的报工数据不为未开工状态,无法删除!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=0 where HInterID=" + HInterID + " and HEntryID=" + HEntryID);
                    oCN.RunProc("delete from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID);
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                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("LEMS/ProcessExchangeArrangement_Add")]
@@ -802,6 +1127,7 @@
            DataSet ds;
            try
            {
                List<object> columnNameList = new List<object>();
                if (HBillSubType == "SUB")
                {
                    //判断是否有查询权限
@@ -859,7 +1185,19 @@
                    }
                    string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)";
                    ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList");
                }   //添加列名
                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;
            }
            catch (Exception e)
            {
@@ -887,6 +1225,7 @@
            DataSet ds;
            try
            {
                //List<object> columnNameList = new List<object>();  //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user))
                {
@@ -927,6 +1266,18 @@
                    string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)";
                    ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList_His");
                }
                //foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用
                //{
                //    Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType
                //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接         // 将列名和数据类型信息拼接成一个JSON格式的字符串
                //    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                //}
                //objJsonResult.code = "1";
                //objJsonResult.count = 1;
                //objJsonResult.Message = "Sucess!";
                //objJsonResult.data = ds.Tables[0];//代码将第一个DataTable(索引为0)赋值给objJsonResult的data属性
                //objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性
            }
            catch (Exception e)
            {
@@ -1271,7 +1622,8 @@
            DataSet ds;
            try
            {
                //判断是否有查询权限
                List<object> columnNameList = new List<object>()
;                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -1296,6 +1648,22 @@
                }
                ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1 " + sWhere + " order by 制单日期 desc,单据号 desc", "h_v_IF_ICMOBillList");
                //添加列名
                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列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                //objJsonResult.code = "1";
                //objJsonResult.count = 1;
                //objJsonResult.Message = "Sucess!";
                //objJsonResult.data = ds.Tables[0];
                //objJsonResult.list = a;
                //return objJsonResult;
            }
            catch (Exception e)
            {
@@ -1307,6 +1675,52 @@
            }
            return GetObjectJson(ds);
        }
        #region 工序流转卡下推生产质量汇报单
        [Route("LEMS/MES_IF_ProcessBillList_Json")]
        [HttpGet]
        public object MES_IF_ProcessBillList_Json(string hinterid, string HEntryID, string user)
        {
            DataSet ds;
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuerySub where hmainid ='" + hinterid+ "' and HEntryID='"+ HEntryID + "'", "h_v_Sc_ProcessExchangeBillQuerySub");
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
            return GetObjectJson(ds);
        }
        #endregion
        #region 工序流转卡下推设备点检参数表
        [Route("LEMS/MES_IF_EquipICMOTechParamList_Json")]
        [HttpGet]
        public object MES_IF_EquipICMOTechParamList_Json(string hinterid, string HEntryID, string user)
        {
            DataSet ds;
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery_TechParam where hmainid ='" + hinterid + "' and HEntryID='" + HEntryID + "'", "h_v_Sc_ProcessExchangeBillQuerySub");
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
            return GetObjectJson(ds);
        }
        #endregion
        #region 生产订单 下查
        /// <summary>
@@ -1327,6 +1741,7 @@
                List<object> columnNameList3 = new List<object>();
                List<object> columnNameList4 = new List<object>();
                List<object> columnNameList5 = new List<object>();
                List<object> columnNameList6 = new List<object>();
                string sql = "exec h_p_Sc_ICMOBillList_LookDown " + HInterID;
                ds = oCN.RunProcReturn(sql, "h_p_Xs_SeOrderBill_lookdown");
@@ -1379,12 +1794,21 @@
                    columnNameList5.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //添加 生产订单变更单 列名
                foreach (DataColumn col in ds.Tables[6].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList6.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                columnNameListSum.Add(columnNameList0);
                columnNameListSum.Add(columnNameList1);
                columnNameListSum.Add(columnNameList2);
                columnNameListSum.Add(columnNameList3);
                columnNameListSum.Add(columnNameList4);
                columnNameListSum.Add(columnNameList5);
                columnNameListSum.Add(columnNameList6);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -1425,6 +1849,44 @@
                {
                      ds = oCN.RunProcReturn("exec [h_p_Sc_ProductionAnalysisReportList] '" + DateYear + "','" + HType + "'", "[h_p_Sc_ProductionAnalysisReportList]");
                }
                //添加列名
                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 螺母检验CCD合格率
        [Route("LEMS/Sc_NutInspectionCCDPassRate")]
        [HttpGet]
        public object Sc_NutInspectionCCDPassRate(string HBatchNo, string user)
        {
            try
            {
                DataSet ds;
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("exec h_p_Sc_NutInspectionCCDPassRate '" + HBatchNo + "'", "h_p_Sc_NutInspectionCCDPassRate");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
@@ -1740,6 +2202,94 @@
        }
        #endregion
        #region 生产订单流转卡 履历条件查询
        [Route("LEMS/GetProcessBillOrICMOBillResumeList")]
        [HttpGet]
        public object GetProcessBillOrICMOBillResumeList(string HInterID,string HEntryID,string sWhere,int type, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                DataSet ds;
                //1表示生产订单
                if(type == 3710)
                {
                    ds = oCN.RunProcReturn($@"select * from
               (select a.HInterID,a.HDate '日期',a.HBillType,x.HName 单据类型,a.HBillNo as '单据号',
                CASE WHEN a.HBillStatus <= 1 THEN '创建' WHEN a.HBillStatus = 2 THEN '已审核' WHEN a.HBillStatus = 3 AND
                a.HCloseType = 0 THEN '自动关闭' WHEN a.HBillStatus = 3 AND
                a.HCloseType = 1 THEN '手动关闭' WHEN a.HBillStatus = 4 THEN '已作废' ELSE '其它状态' END AS 单据状态,
                a.HMaker AS 制单人, a.HMakeDate AS 制单日期,a.HChecker AS 审核人, a.HCheckDate AS 审核日期, a.HUpDater AS 修改人, a.HUpDateDate AS 修改日期,
                a.HCloseMan AS 关闭人, a.HCloseDate AS 关闭日期, a.HDeleteMan AS 作废人, a.HDeleteDate AS 作废日期
                from (
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType  from Sc_ICMOBillMain where HInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_MESBeginWorkBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_FirstPieceCheckBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_PatrolProcCheckBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_PatrolProcCheckOtherBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_StationInBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_StationOutBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from SB_EquipICMOTechParamBillMain where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} UNION ALL
                select m.HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,m.HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,m.HCloseType from Sc_MouldUpperBillMain as m,Sc_MouldUpperBillSub as s
                where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} and m.HInterID = s.HInterID  UNION ALL
                select m.HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,m.HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,m.HCloseType from Sc_MouldLowerBillMain as m,Sc_MouldLowerBillSub as s
                where HICMOInterID = {HInterID} and HICMOEntryID = {HEntryID} and m.HInterID = s.HInterID
                )as a,Xt_BillType as x
                where a.HBillType = x.HNumber ) AS a where 1=1 " + sWhere +
                @" ORDER BY 日期 ASC;", "Sc_ICMOBillResume");
                }
                else
                {
                    ds = oCN.RunProcReturn($@"select * from
               (select a.HInterID,a.HDate '日期',a.HBillType,x.HName 单据类型,a.HBillNo as '单据号',
                CASE WHEN a.HBillStatus <= 1 THEN '创建' WHEN a.HBillStatus = 2 THEN '已审核' WHEN a.HBillStatus = 3 AND
                a.HCloseType = 0 THEN '自动关闭' WHEN a.HBillStatus = 3 AND
                a.HCloseType = 1 THEN '手动关闭' WHEN a.HBillStatus = 4 THEN '已作废' ELSE '其它状态' END AS 单据状态,
                a.HMaker AS 制单人, a.HMakeDate AS 制单日期,a.HChecker AS 审核人, a.HCheckDate AS 审核日期, a.HUpDater AS 修改人, a.HUpDateDate AS 修改日期,
                a.HCloseMan AS 关闭人, a.HCloseDate AS 关闭日期, a.HDeleteMan AS 作废人, a.HDeleteDate AS 作废日期
                from (
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType  from Sc_ProcessExchangeBillMain where HInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_MESBeginWorkBillMain where HProcExchInterID = {HInterID}  UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_FirstPieceCheckBillMain where HProcExchInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_PatrolProcCheckBillMain where HProcExchInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from QC_PatrolProcCheckOtherBillMain where HProcExchInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_StationInBillMain where HProcExchInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from Sc_StationOutBillMain where HProcExchInterID = {HInterID} UNION ALL
                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType from SB_EquipICMOTechParamBillMain where HProcExchInterID = {HInterID} UNION ALL
                select m.HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,m.HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,m.HCloseType from Sc_MouldUpperBillMain as m,Sc_MouldUpperBillSub as s
                where s.HProcExchInterID = {HInterID} and m.HInterID = s.HInterID  UNION ALL
                select m.HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,m.HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,m.HCloseType from Sc_MouldLowerBillMain as m,Sc_MouldLowerBillSub as s
                where s.HProcExchInterID = {HInterID} and m.HInterID = s.HInterID
                )as a,Xt_BillType as x
                where a.HBillType = x.HNumber ) AS a where 1=1 " + sWhere +
                @" ORDER BY 日期 ASC;", "Sc_ProcessExchangeBillResume");
                }
                //添加动态列信息
                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
        /// <summary>
        /// 返回工序委外接收单列表
        ///参数:string sql。
@@ -1783,7 +2333,7 @@
            {
                List<object> columnNameList = new List<object>();
               
                //添加列名
               //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
@@ -1794,8 +2344,9 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
@@ -2858,6 +3409,44 @@
        #endregion
        #region 报表查看权限控制
        /// <summary>
        ///参数:string HInterID。
        ///返回值:object。
        /// </summary>
        [Route("LMES/getReportByModRightNameCheck")]
        [HttpGet]
        public object getReportByModRightNameCheck(string ModRightNameCheck, string user)
        {
            try
            {
                string s = "";
                //查看权限
                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}