using DBUtility; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers.CJGL { public class Mes_OrderProcFlowAllReportController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); #region 车间工序全程跟踪报表 查询 [Route("Mes_OrderProcFlowAllReport/OrderProcFlowAllReportList")] [HttpGet] public object OrderProcFlowAllReportList(string sWhere) { try { //反序列化传递的值 ds = oCN.RunProcReturn($"exec h_p_Mes_OrderProcFlowAllReport " +sWhere+"", "h_p_Mes_OrderProcFlowAllReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 工序在制品报表(纵向) 查询 [Route("Mes_OrderProcFlowAllReport/WIPProcReportList")] [HttpGet] public object WIPProcReportList(string sWhere) { try { //反序列化传递的值 ds = oCN.RunProcReturn($"exec h_p_MES_WIPProcReport_New " + sWhere + "", "h_p_MES_WIPProcReport_New"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 不良明细良率报表 查询 [Route("Mes_OrderProcFlowAllReport/DefectiveDetailedYieldReportList")] [HttpGet] public object DefectiveDetailedYieldReportList(string sWhere) { try { //反序列化传递的值 ds = oCN.RunProcReturn("select * from h_v_DefectiveDetailedYieldReport where 1=1 "+sWhere+" order by HProcID", "h_v_DefectiveDetailedYieldReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 车间生产汇报统计表 查询 [Route("Mes_OrderProcFlowAllReport/StationOutSumReportList")] [HttpGet] public object StationOutSumReportList(string sWhere) { try { //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_StationOutSumReport_New " + sWhere + "", "h_p_Sc_StationOutSumReport_New"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 计件工资报表 查询 [Route("Mes_OrderProcFlowAllReport/EmployeePiecePayReport")] [HttpGet] public object EmployeePiecePayReport(string sWhere, string user) { try { //获取系统参数 string Ret = ""; if (oSystemParameter.ShowBill(ref Ret)) { //判断客户为龙山汽配 if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") { //获取需要拼接的字符串 string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "计件工资报表"); if (sql_splice != "") { sWhere += sql_splice; } else { string czymc = ""; ds = oCN.RunProcReturn("select * from gy_czygl where Czymc='" + user + "'", "gy_czygl"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { czymc += Convert.ToString(ds.Tables[0].Rows[i]["czymc"]) + ","; } sWhere += ",''"; } } } //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_EmployeePiecePayReport " + sWhere + "", "h_p_Sc_EmployeePiecePayReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 计件工资汇总报表 查询 [Route("Mes_OrderProcFlowAllReport/EmployeePiecePaySumReport")] [HttpGet] public object EmployeePiecePaySumReport(string sWhere, string user) { try { //获取系统参数 string Ret = ""; if (oSystemParameter.ShowBill(ref Ret)) { //判断客户为龙山汽配 if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") { //获取需要拼接的字符串 string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "计件工资汇总报表"); if (sql_splice != "") { sWhere += sql_splice; } else { string czymc = ""; ds = oCN.RunProcReturn("select * from gy_czygl where Czymc='" + user + "'", "gy_czygl"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { czymc += Convert.ToString(ds.Tables[0].Rows[i]["czymc"]) + ","; } sWhere += ",''"; } } } //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_EmployeePiecePaySumReport " + sWhere + "", "h_p_Sc_EmployeePiecePaySumReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 工资汇报日报表 查询 [Route("Mes_OrderProcFlowAllReport/EmployeePieceWorkReport")] [HttpGet] public object EmployeePieceWorkReport(string sWhere, string user) { try { //获取系统参数 string Ret = ""; if (oSystemParameter.ShowBill(ref Ret)) { //判断客户为龙山汽配 if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") { //获取需要拼接的字符串 string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序汇报日报表"); if (sql_splice != "") { sWhere += sql_splice; } else { string czymc = ""; ds = oCN.RunProcReturn("select * from gy_czygl where Czymc='" + user + "'", "gy_czygl"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { czymc += Convert.ToString(ds.Tables[0].Rows[i]["czymc"]) + ","; } sWhere += ",''"; } } } //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_EmployeePieceWorkReport " + sWhere + "", "h_p_Sc_EmployeePieceWorkReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 生产车间工序报表 查询 [Route("Mes_OrderProcFlowAllReport/WorkShopProcessWIPReport")] [HttpGet] public object WorkShopProcessWIPReport(string sWhere,string user) { try { //获取系统参数 string Ret = ""; if (oSystemParameter.ShowBill(ref Ret)) { //判断客户为龙山汽配 if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") { //获取需要拼接的字符串 string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "生产车间工序报表"); if(sql_splice != "") { sWhere += sql_splice; } else { string czymc = ""; ds = oCN.RunProcReturn("select * from gy_czygl where Czymc='" + user + "'", "gy_czygl"); for(int i = 0; i < ds.Tables[0].Rows.Count; i++) { czymc += Convert.ToString(ds.Tables[0].Rows[i]["czymc"])+","; } sWhere += ",''"; } } } //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_WorkShopProcessWIPReport " + sWhere + "", "h_p_Sc_WorkShopProcessWIPReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 工序在制品报表 查询 [Route("Mes_OrderProcFlowAllReport/WorkShopProcessWIPSumReport")] [HttpGet] public object WorkShopProcessWIPSumReport(string sWhere, string user) { try { //获取系统参数 string Ret = ""; if (oSystemParameter.ShowBill(ref Ret)) { //判断客户为龙山汽配 if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") { //获取需要拼接的字符串 string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序在制品报表"); if (sql_splice != "") { sWhere += sql_splice; } else { string czymc = ""; ds = oCN.RunProcReturn("select * from gy_czygl where Czymc='" + user + "'", "gy_czygl"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { czymc += Convert.ToString(ds.Tables[0].Rows[i]["czymc"]) + ","; } sWhere += ",''"; } } } //反序列化传递的值 ds = oCN.RunProcReturn("exec h_p_Sc_WorkShopProcessWIPSumReport " + sWhere + "", "h_p_Sc_WorkShopProcessWIPSumReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 产品工艺路线展开报表 查询 [Route("Mes_OrderProcFlowAllReport/RoutingBillMulLevBOMReportList")] [HttpGet] public object RoutingBillMulLevBOMReportList(string sWhere) { try { //反序列化传递的值 ds = oCN.RunProcReturn($"exec h_p_Sc_RoutingBillMulLevBOMReport " + sWhere + "", "h_p_Sc_RoutingBillMulLevBOMReport"); List listCol = new List(); foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; listCol.Add(JsonConvert.DeserializeObject(str)); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = listCol; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 工序异常过站报表 /// /// 工序异常过站报表 /// /// [Route("Mes_OrderProcFlowAllReportController/GetSc_ProcessErrStationReport_Json")] [HttpGet] public object GetSc_ProcessErrStationReport_Json(string sWhere,string user) { try { if (!DBUtility.ClsPub.Security_Log("Sc_ProcessErrStationReport", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = oCN.RunProcReturn("exec h_p_Sc_ProcessErrStationReport " + sWhere, "h_p_Sc_ProcessErrStationReport"); List columnNameList = new List(); //添加列名 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 = "0"; objJsonResult.count = 1; objJsonResult.Message = "成功!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询工序异常过站报表信息失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }