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.
206 lines
9.5 KiB
206 lines
9.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Validation;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Warehouse.Models;
|
|
using Warehouse.Models.mesModel;
|
|
using Z.EntityFramework.Plus;
|
|
|
|
namespace Warehouse.DAL.YieldByStationAndEqp
|
|
{
|
|
public class YieldByStationAndEqp
|
|
{
|
|
|
|
private Boolean checkEmpty(dynamic para)
|
|
{
|
|
|
|
if (para.StartDTFlg == "N" && para.EndDTFlg == "N"
|
|
&& string.IsNullOrEmpty(para.WorkShop)
|
|
&& string.IsNullOrEmpty(para.ModuleID)
|
|
&& string.IsNullOrEmpty(para.PalletNo)
|
|
&& string.IsNullOrEmpty(para.ContainerNo)
|
|
&& string.IsNullOrEmpty(para.WorkOrder)
|
|
&& string.IsNullOrEmpty(para.ProduceNotice)
|
|
&& string.IsNullOrEmpty(para.WareHouseNo)
|
|
&& string.IsNullOrEmpty(para.StockNo)
|
|
&& string.IsNullOrEmpty(para.Station)
|
|
&& string.IsNullOrEmpty(para.Banci))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public dynamic Station_capacity(dynamic para)
|
|
{
|
|
using (var context = new mesModel())
|
|
{
|
|
string sql = string.Empty;
|
|
string strWhere = string.Empty;
|
|
string strIVWhere = string.Empty;
|
|
string strELWhere = string.Empty;
|
|
string strPackWhere = string.Empty;
|
|
|
|
if (checkEmpty(para))
|
|
{
|
|
strWhere += " and 1=2 ";
|
|
strIVWhere += " and 1=2 ";
|
|
strELWhere += " and 1=2 ";
|
|
strPackWhere += " and 1=2 ";
|
|
}
|
|
else
|
|
{
|
|
if (para.StartDTFlg == "Y")
|
|
{
|
|
strWhere += " and a.wks_visit_date >= '" + para.StartDateTime + "' ";
|
|
strIVWhere += " and a.wks_visit_date >= '" + para.StartDateTime + "' ";
|
|
strELWhere += " and a.wks_visit_date >= '" + para.StartDateTime + "' ";
|
|
strPackWhere += " and b.pack_date >= '" + para.StartDateTime + "' ";
|
|
}
|
|
if (para.EndDTFlg == "Y")
|
|
{
|
|
strWhere += " and a.wks_visit_date <= '" + para.EndDateTime + "' ";
|
|
strIVWhere += " and a.wks_visit_date <= '" + para.EndDateTime + "' ";
|
|
strELWhere += " and a.wks_visit_date <= '" + para.EndDateTime + "' ";
|
|
strPackWhere += " and b.pack_date <= '" + para.EndDateTime + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(para.WorkShop))
|
|
{
|
|
strWhere += " and b.area_code = '" + para.WorkShop + "' ";
|
|
strIVWhere += " and c.area_code = '" + para.WorkShop + "' ";
|
|
strELWhere += " and c.area_code = '" + para.WorkShop + "' ";
|
|
strPackWhere += " and c.area_code= '" + para.WorkShop + "' ";
|
|
}
|
|
//if (!string.IsNullOrEmpty(para.Banci))
|
|
//{
|
|
// strWhere += " and a.banci = '" + para.Banci + "' ";
|
|
// strIVWhere += " and 1=2 ";
|
|
// strELWhere += " and 1=2 ";
|
|
// strPackWhere += " and a.banci = '" + para.Banci + "' ";
|
|
//}
|
|
|
|
}
|
|
|
|
string sql_HJ = @" SELECT '焊接', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'M10'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
string sql_DC = @" SELECT '叠层', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'M15'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
string sql_CY = @" SELECT '层压', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'N30'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
string sql_ZK = @" SELECT '装框', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'M45'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
string sql_QX = @" SELECT '清洗', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'N50'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
/////
|
|
string sql_IV = @"SELECT
|
|
'IV测试', a.wks_id 设备, count(*) 产量, c.area_code 车间
|
|
FROM
|
|
mes_level2_iface.dbo.iv a
|
|
left join mes_main.dbo.assembly_status b
|
|
on a.serial_nbr = b.serial_nbr
|
|
left join mes_main.dbo.wo_mfg c
|
|
on b.workorder = c.workorder " + strIVWhere +
|
|
" group by a.wks_id , c.area_code ";
|
|
|
|
/////
|
|
string sql_EL = @"SELECT
|
|
'EL测试', a.wks_id 设备, count(*) 产量, c.area_code 车间
|
|
FROM
|
|
mes_level2_iface.dbo.el a
|
|
left join mes_main.dbo.assembly_status b
|
|
on a.serial_nbr = b.serial_nbr
|
|
left join mes_main.dbo.wo_mfg c
|
|
on b.workorder=c.workorder " + strELWhere +
|
|
"group by a.wks_id , c.area_code ";
|
|
|
|
string sql_QJ = @" SELECT '全检', b.wks_id 设备, count(*) 产量, b.area_code 车间
|
|
FROM mes_main.dbo.trace_workstation_visit a
|
|
left join mes_main.dbo.config_workstation b
|
|
on a.wks_id = b.wks_id
|
|
where b.process_code = 'N60'" + strWhere +
|
|
" group by a.wks_id,b.wks_id,b.area_code ";
|
|
|
|
string sql_BZ = @"SELECT '包装', b.wks_id 设备, COUNT(a.serial_nbr) 产量, c.area_code 车间
|
|
FROM[mes_main].[dbo].[assembly_status] a
|
|
left join mes_main.dbo.pack_pallets b
|
|
on a.pallet_nbr = b.pallet_nbr
|
|
left join mes_main.dbo.config_workstation c
|
|
on b.wks_id = c.wks_id
|
|
where b.pallet_status > '0'
|
|
" + strPackWhere +
|
|
"group by b.wks_id,c.area_code ";
|
|
if (!string.IsNullOrEmpty(para.Station))
|
|
{
|
|
|
|
switch (para.Station)
|
|
{
|
|
case "M10":
|
|
sql = sql_HJ;
|
|
break;
|
|
case "M15":
|
|
sql = sql_DC;
|
|
break;
|
|
case "N30":
|
|
sql = sql_CY;
|
|
break;
|
|
case "M45":
|
|
sql = sql_ZK;
|
|
break;
|
|
case "N50":
|
|
sql = sql_QX;
|
|
break;
|
|
case "N60":
|
|
sql = sql_QJ;
|
|
break;
|
|
case "P100":
|
|
sql = sql_BZ;
|
|
break;
|
|
default:
|
|
sql = sql_HJ;
|
|
break;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
sql = sql_HJ +
|
|
" union all " + sql_DC +
|
|
" union all " + sql_CY +
|
|
" union all " + sql_ZK +
|
|
" union all " + sql_QX +
|
|
" union all " + sql_IV +
|
|
" union all " + sql_EL +
|
|
" union all " + sql_QJ +
|
|
" union all " + sql_BZ;
|
|
}
|
|
|
|
var res = context.DynamicListFromSql(sql, null);
|
|
return res;
|
|
}
|
|
}
|
|
}
|
|
}
|