旧版报表、仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

121 lines
4.3 KiB

using JHReport.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Warehouse.Models.mesModel;
namespace Warehouse.DAL.YL
{
public class WIPStatisticsDal
{
//在制统计
public List<dynamic> StationNbrAndGoing(string StartDateTime, string EndDateTime, string WorkShop, string workorder, string saleorder)
{
using (var context = new mesModel())
{
string sql = string.Empty;
string strWhere = string.Empty;
if (!string.IsNullOrEmpty(StartDateTime))
{
strWhere += " and a.wks_visit_date >= '" + StartDateTime + "' ";
}
if (!string.IsNullOrEmpty(EndDateTime))
{
strWhere += " and a.wks_visit_date <= '" + EndDateTime + "' ";
}
if (!string.IsNullOrEmpty(WorkShop))
{
strWhere += "and b.area_code = '" + WorkShop + "' ";
}
//if (!string.IsNullOrEmpty(wks))
//{
// strWhere += " and a.wks_id = '" + wks + "' ";
//}
if (!string.IsNullOrEmpty(workorder))
{
strWhere += " and f.workorder = '" + workorder + "' ";
}
if (!string.IsNullOrEmpty(saleorder))
{
strWhere += " and f.sale_order = '" + saleorder + "' ";
}
sql = @"select FA.process_code,FA.descriptions,FA.workshop,FA.station_nbr,FB.going_nbr from
(
SELECT
e.descriptions as workshop,
e.area_code,
b.process_code ,
d.descriptions,
COUNT(distinct a.serial_nbr)as station_nbr
FROM (select distinct serial_nbr,wks_id,max(wks_visit_date)as wks_visit_date
from mes_main.dbo.trace_workstation_visit
group by serial_nbr,wks_id) a
LEFT join mes_main.dbo.config_workstation b
on a.wks_id = b.wks_id
LEFT JOIN mes_main.dbo.assembly_status c
on a.serial_nbr =c.serial_nbr
LEFT JOIN mes_main.dbo.df_processes d
on b.process_code = d.process_code
left join mes_main.dbo.df_areas e
on b.area_code= e.area_code
LEFT JOIN mes_main.DBO.wo_mfg f
ON f.workorder = c.workorder
where 1=1 " + strWhere + @"
group by b.process_code,b.area_code,d.descriptions,e.descriptions,e.area_code
--order by RIGHT(b.process_code,2)
)FA
LEFT JOIN
(
select COUNT(zzsl.serial_nbr) as going_nbr,zzsl.ZZZD,zzsl.area_code from
(
select a.serial_nbr,MAX(a.wks_visit_date) as wks_visit_date,max(g.process_code) AS ZZZD,b.area_code
from mes_main.dbo.trace_workstation_visit a
left join mes_main.dbo.assembly_status e
on a.serial_nbr = e.serial_nbr
left join mes_main.dbo.config_products c
on e.product_code = c.product_code
left join mes_main.dbo.config_workstation b
on a.wks_id = b.wks_id
left join mes_main.dbo.config_process d
on c.process_group_id = d.process_group_id
and e.process_code = d.process_code
left join mes_main.dbo.config_process g
on c.process_group_id = g.process_group_id
and g.process_idx-1 = d.process_idx
LEFT JOIN mes_main.DBO.wo_mfg f
ON f.workorder = e.workorder
where 1=1 " + strWhere + @"
group by a.serial_nbr,b.area_code
)zzsl
group by zzsl.ZZZD,zzsl.area_code
)FB
ON FA.process_code = FB.ZZZD and FA.area_code = FB.area_code
order by RIGHT(FA.process_code,2) ";
var res = context.DynamicListFromSql(sql, null);
//DataTable dt = ToDataTable(res.ToList());
return res.ToList();
}
}
//在制品弹窗
public List<dynamic> Produinc(string workshop, string workorder, string saleorder, string bt, string et, string field)
{
using (var context = new mesModel())
{
string sql = string.Empty;
ReportDal report = new ReportDal();
sql = report.ProduincSql(workshop, workorder, saleorder, bt, et, field);
var res = context.DynamicListFromSql(sql, null);
return res.ToList();
}
}
}
}