using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.MESReport.Entity.LineQTY; using QMAPP.MESReport.DAL.LineQTY; using QMAPP.BLL; using QMFrameWork.Data; using QMAPP.Entity; using System.Data; using QMAPP.BLL.Sys; using QMAPP.Entity.Sys; using QMAPP.MD.BLL; using QMAPP.MD.Entity; using QMAPP.MESReport.Entity.Tables; namespace QMAPP.MESReport.BLL.LineQTY { /// /// 返修率统计 /// 于子清 /// 2017-10-25 /// public class RepairRateCountBLL : BaseBLL { int tday = -7; //报废统计-柱状图 public DataResult> GetAllList(QTYCompletionRateDModel condition) { DataResult> result = new DataResult>(); try { result.Result = new RepairRateCountDAL().GetAllList(condition); result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } //注塑-报废统计 public DataResult> GetAllListNew1(QTYCompletionRateDModel condition) { DataResult> result = new DataResult>(); try { string sql = "SELECT count(1) as COMPLETE_QTY,MATERIAL_CODE FROM T_AW_MAINOPERATION where CREATEDATE between DATEADD(day,-7,getdate()) and getdate() and WORKCENTER_CODE='INJECT' group by MATERIAL_CODE"; var qtys = new RepairRateCountDAL().GetAllListNew("INJECT", tday, sql); //var materials = new MaterialBLL().GetAllList(new Material()); //foreach (QTYCompletionRateDModel item in qtys) // { // //处理人 // if (!string.IsNullOrEmpty(item.MATERIAL_CODE)) // { // var material = materials.FirstOrDefault(x => x.MATERIAL_CODE == item.MATERIAL_CODE); // if (material != null) // { // item.MATERIAL_NAME = material.MATERIAL_NAME; // item.MATERIAL_SHORT = material.MATERIAL_SHORT; // } // } // } result.Result = qtys; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } //门板-报废统计 public DataResult> GetAllListNew2(QTYCompletionRateDModel condition) { DataResult> result = new DataResult>(); try { string sql = "SELECT count(1) as COMPLETE_QTY,.T_AW_PRODUCT.MATERIAL_CODE FROM T_AW_PRODUCT left join T_MD_MATERIAL M ON T_AW_PRODUCT.MATERIAL_CODE=M.MATERIAL_CODE where T_AW_PRODUCT.CREATEDATE between DATEADD(day,-7,getdate()) and getdate() and M.PROJECTCODE='VW331 DP' and exists(select 1 from T_MD_MATERIAL_CLASS mc where mc.MATERIAL_TYPE_CODE=MATERIAL_TYPE and mc.MATERIAL_ATTRIBUTE='2') group by T_AW_PRODUCT.MATERIAL_CODE"; var qtys = new RepairRateCountDAL().GetAllListNew("BORADPASSY", tday, sql); //var materials = new MaterialBLL().GetAllList(new Material()); //foreach (QTYCompletionRateDModel item in qtys) //{ // //处理人 // if (!string.IsNullOrEmpty(item.MATERIAL_CODE)) // { // var material = materials.FirstOrDefault(x => x.MATERIAL_CODE == item.MATERIAL_CODE); // if (material != null) // { // item.MATERIAL_NAME = material.MATERIAL_NAME; // item.MATERIAL_SHORT = material.MATERIAL_SHORT; // } // } //} result.Result = qtys; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } //仪表板-报废统计 public DataResult> GetAllListNew3(QTYCompletionRateDModel condition) { DataResult> result = new DataResult>(); try { string sql = "SELECT count(1) as COMPLETE_QTY,.T_AW_PRODUCT.MATERIAL_CODE FROM T_AW_PRODUCT left join T_MD_MATERIAL M ON T_AW_PRODUCT.MATERIAL_CODE=M.MATERIAL_CODE where T_AW_PRODUCT.CREATEDATE between DATEADD(day,-7,getdate()) and getdate() and M.PROJECTCODE='VW331/5CN IP' and exists(select 1 from T_MD_MATERIAL_CLASS mc where mc.MATERIAL_TYPE_CODE=MATERIAL_TYPE and mc.MATERIAL_ATTRIBUTE='2') group by T_AW_PRODUCT.MATERIAL_CODE"; var qtys = new RepairRateCountDAL().GetAllListNew("BORAIPASSY", tday, sql); //var materials = new MaterialBLL().GetAllList(new Material()); //foreach (QTYCompletionRateDModel item in qtys) //{ // //处理人 // if (!string.IsNullOrEmpty(item.MATERIAL_CODE)) // { // var material = materials.FirstOrDefault(x => x.MATERIAL_CODE == item.MATERIAL_CODE); // if (material != null) // { // item.MATERIAL_NAME = material.MATERIAL_NAME; // item.MATERIAL_SHORT = material.MATERIAL_SHORT; // } // } //} result.Result = qtys; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } /// /// 注塑返修率 /// /// public DataResult> GetInjectReworkRate() { DataResult> result = new DataResult>(); try { var qtys = new RepairRateCountDAL().GetInjectReworkRate(); result.Result = qtys; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } /// /// 仪表板、门板返修率 /// /// public DataResult> GetReworkRate(string project) { DataResult> result = new DataResult>(); try { var qtys = new RepairRateCountDAL().GetReworkRate(project); result.Result = qtys; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } #region 导出数据 /// /// 获取导出的数据 /// /// 查询条件 /// 数据 public DataResult GetExportData(QTYCompletionRateDModel model) { DataResult result = new DataResult(); try { result.IsSuccess = true; result.Result = new RepairRateCountDAL().GetExportData(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = "导出错误!"; } return result; } public DataResult GetExportDataReason(RepairRateCountDModel model) { DataResult result = new DataResult(); try { result.IsSuccess = true; result.Result = new RepairRateCountDAL().GetExportDataReason(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = "导出错误!"; } return result; } #endregion //报废原因、趋势统计-饼状图-柱状图 public DataResult> GetMenderReason(RepairRateCountDModel condition) { DataResult> result = new DataResult>(); try { result.Result = new RepairRateCountDAL().GetMenderReason(condition); result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Msg = ex.ToString(); return result; } } } }