|
|
using System; using System.Data.SqlTypes; using System.Collections;
using System.Linq; using System.Data.Linq; using System.Xml; using System.IO; using ICSSoft.Base.Config.AppConfig; using System.Collections.Specialized; using ICSSoft.Frame.Helper; using ICSSoft.Frame.Data.Entity; using ICSSoft.Frame.DataConnect.Action;
namespace ICSSoft.Frame.DataConnect { /// <summary>
/// ReportHelper ��ժҪ˵����
/// </summary>
public class ReportHelper { private const string OutLineResource = "OUTLINERESOURCE"; private FramDataContext _domainDataProvider = null;
// public ReportHelper()
// {
// }
public ReportHelper(FramDataContext domainDataProvider) { this._domainDataProvider = domainDataProvider; }
public FramDataContext DataProvider { get { return _domainDataProvider; } }
public int WeekOfYear(string Date) { int weekOfYear =0; String sqlWeek = "select datepart(week,'"+Date+"') ";
var query = this.DataProvider.ExecuteQuery<int>(sqlWeek); weekOfYear = query.First<int>(); if (weekOfYear > 0) { return weekOfYear; } else { weekOfYear = 1; } return weekOfYear; }
private static void DecodeDateWeek(DateTime dt,out int year,out int weekOfYear,out int dayOfWeek) { int dayOfYear = dt.DayOfYear; int monthOfYear = dt.Month; year = dt.Year; dayOfWeek = (int)dt.DayOfWeek; DateTime startDate = new DateTime(dt.Year,1,1); System.DayOfWeek startDayOfWeek = startDate.DayOfWeek; System.DayOfWeek endDayOfWeek = dt.DayOfWeek; if((startDayOfWeek == DayOfWeek.Friday)||(startDayOfWeek==DayOfWeek.Saturday)||(startDayOfWeek==DayOfWeek.Sunday)) { dayOfYear = dayOfYear - (7- (int)startDayOfWeek); } else { dayOfYear = dayOfYear + (int)startDayOfWeek; } //dayOfYear+startDayOfWeek <7 ��Ӧ��Ϊȥ������
if(dayOfYear <0) { DecodeDateWeek(startDate.AddDays(-1),out year,out weekOfYear,out dayOfWeek); } weekOfYear = dayOfYear/7; if( SqlInt32.Mod(dayOfYear,7) != 0) { weekOfYear++; } if(weekOfYear > 52) { endDayOfWeek = startDayOfWeek; if(DateTime.IsLeapYear(dt.Year)) { if((endDayOfWeek == DayOfWeek.Sunday)||(endDayOfWeek == DayOfWeek.Monday)) { endDayOfWeek ++; } if((endDayOfWeek==DayOfWeek.Monday)||(endDayOfWeek==DayOfWeek.Tuesday)||(endDayOfWeek==DayOfWeek.Wednesday)) { year ++; weekOfYear = 1; } } } }
private bool IsLastOP(string moCode,string routeCode,string opCode) { if (routeCode==string.Empty) return false; DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
return dataCollectFacade.OPIsMORouteLastOP(moCode,routeCode,opCode); }
private bool IsMidOutputOP(string itemCode,string routeCode,string opCode,ProductInfo product) { if (routeCode.Trim()==string.Empty) { //BaseModelFacade itemFacade = new BaseModelFacade(this.DataProvider);
object obj = null;// itemFacade.GetOperation(opCode);
if(obj == null) { /*Burn In ©ɨʱ����������FT����ʾ���ò�Ʒ�Ѿ��깤���߱��滻��������ʾҪ�ģ��Ա���USER֪�����������깤�ˣ�����ʾҪ�ӵ�һվͶ�롣 ��������������ʾ��ʱ�����ָò�Ʒ�Ѿ��깤���Ȳ�Ҫֱ�ӱ��������ں����ټ�һ�����飬�������깤�������������Ͼ������������Ǻܶ࣬�������ܷ����Ĺ��ǿ����ų����� * */ if(product.LastSimulation != null && product.LastSimulation.ISCOM == "1") { throw new Exception("$CS_PRODUCT_ALREADY_COMPLETE $CS_Param_OPCode =" + product.LastSimulation.OPCODE); } else { throw new Exception("$CS_Route_Failed_GetNotNextOP"); } }
return FormatHelper.StringToBoolean( ((ICSOP)obj).OPCONTROL,(int)OperationList.MidistOutput); } else { //ItemFacade itemFacade = new ItemFacade(this.DataProvider);
object obj = null; if(product.CurrentItemRoute2OP != null) { obj = product.CurrentItemRoute2OP; } else { obj = null;// itemFacade.GetItemRoute2Operation(itemCode, routeCode, opCode);
} return FormatHelper.StringToBoolean(((ICSITEMROUTE2OP)obj).OPCONTROL, (int)OperationList.MidistOutput); } }
//���� �ж��Ƿ����м�Ͷ�빤��
private bool IsMidInputOP(string itemCode,string routeCode,string opCode,ProductInfo product) { //return false;
if (routeCode.Trim()==string.Empty) { //BaseModelFacade itemFacade = new BaseModelFacade(this.DataProvider);
object obj = null;//itemFacade.GetOperation(opCode);
if(obj == null) { /*Burn In ©ɨʱ����������FT����ʾ���ò�Ʒ�Ѿ��깤���߱��滻��������ʾҪ�ģ��Ա���USER֪�����������깤�ˣ�����ʾҪ�ӵ�һվͶ�롣 ��������������ʾ��ʱ�����ָò�Ʒ�Ѿ��깤���Ȳ�Ҫֱ�ӱ��������ں����ټ�һ�����飬�������깤�������������Ͼ������������Ǻܶ࣬�������ܷ����Ĺ��ǿ����ų����� * */ if(product.LastSimulation != null && product.LastSimulation.ISCOM == "1") { throw new Exception("$CS_PRODUCT_ALREADY_COMPLETE $CS_Param_OPCode =" + product.LastSimulation.OPCODE); } else { throw new Exception("$CS_Route_Failed_GetNotNextOP"); } }
return FormatHelper.StringToBoolean( ((ICSOP)obj).OPCONTROL,(int)OperationList.MidistInput); } else { //ItemFacade itemFacade = new ItemFacade(this.DataProvider);
object obj = null; if(product.CurrentItemRoute2OP != null) { obj = product.CurrentItemRoute2OP; } else { obj = null;//itemFacade.GetItemRoute2Operation(itemCode,routeCode,opCode);
} return FormatHelper.StringToBoolean( ((ICSITEM2ROUTE)obj).ROUTECODE,(int)OperationList.MidistInput); } }
/// <summary>
/// By Line ͳ�Ʋ�����NG��ֱͨ��
/// ��������
/// </summary>
/// <param name="domainDataProvider"></param>
/// <param name="actionType"></param>
/// <param name="product"></param>
/// <returns></returns>
public Messages ReportLineQuanMaster(FramDataContext domainDataProvider, string actionType, ProductInfo product) { return ReportLineQuanMaster(domainDataProvider, actionType, product, null); }
// ��չһ����ActionCheckStatus�����ķ���
public Messages ReportLineQuanMaster(FramDataContext domainDataProvider, string actionType, ProductInfo product, ActionCheckStatus actionCheckStatus) { Messages messages=new Messages();
ICSReport reportFacade = new ICSReport(domainDataProvider); //TSFacade tSFacade = new TSFacade(domainDataProvider);
//MOFacade mOFacade = new MOFacade(domainDataProvider);
int ngtimes = 0; int qty = 0; int allqty = 0; int inputQty = 0; int moInputQty = 0; int moAllGoodQty = 0; try { //QtyFlag��������
string flag = String.Empty; bool midOP = false; bool midInputOP = false;
if (actionCheckStatus == null || actionCheckStatus.IsMidOutputOP == string.Empty) { if(IsMidOutputOP(product.NowSimulationReport.ITEMCODE,product.NowSimulationReport.ROUTECODE,product.NowSimulationReport.OPCODE,product)) { midOP = true; } if (actionCheckStatus != null) { actionCheckStatus.IsMidOutputOP = midOP.ToString(); } } else { midOP = Convert.ToBoolean(actionCheckStatus.IsMidOutputOP); } if (actionCheckStatus == null || actionCheckStatus.IsMidInputOP == string.Empty) { //�м�Ͷ��
if(IsMidInputOP(product.NowSimulationReport.ITEMCODE,product.NowSimulationReport.ROUTECODE,product.NowSimulationReport.OPCODE,product)) { midInputOP = true; } if (actionCheckStatus != null) { actionCheckStatus.IsMidInputOP = midInputOP.ToString(); } } else { midInputOP = Convert.ToBoolean(actionCheckStatus.IsMidInputOP); }
//�Ƿ�Ϊ��������
if (actionCheckStatus == null || actionCheckStatus.IsLastOP == string.Empty) { if (IsLastOP(product.NowSimulationReport.MOCODE,product.NowSimulationReport.ROUTECODE,product.NowSimulationReport.OPCODE))//�Ƿ�Ϊ��������
flag = "Y"; else flag = "N"; if (actionCheckStatus != null) { actionCheckStatus.IsLastOP = flag; } } else { flag = actionCheckStatus.IsLastOP; }
int iNGStart = 0;
int iMoNGStart = 0;
#region ��������
//���м�Ͷ�빤��Ͷ���IJ�������Ʒ���Dz���Ʒ,����ΪͶ�����ļ���.�����ڼ���.
if(midInputOP) { inputQty = Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE); }
if (product.NowSimulation.PRODUCTSTATUS == "GOOD" && product.NowSimulation.LACTION != ActionType.DataCollectAction_GoMO) {
if (flag == "Y" || midOP)//�Ƿ�Ϊ�����������м����㹤��
{ if(product.NowSimulation != null) { //iNGStart = tSFacade.QueryTSCountByLine(
// product.NowSimulationReport.RCARD
// ,product.NowSimulationReport.SSCODE
// ,Convert.ToInt32(product.NowSimulationReport.RCARDSEQ));
//iMoNGStart = tSFacade.QueryTSCountByMo(
// product.NowSimulation.RCARD
// ,product.NowSimulation.MOCODE);
}
qty = Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE); //ֱͨ������
//if (
// iNGStart == 0 && IDIsInRejectCount(product.NowSimulationReport.RCARD,product.NowSimulationReport.SSCODE)==0)
//{
// //reportRealtimeLineQty.AllGoodQty += 1 * product.NowSimulation.IDMERGERULE;
// allqty = Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE);
//}
//����ֱ̨ͨ��
#region �йز�����Ͷ�����������ʡ�ֱͨ�ʵIJ���˵����
/*3. ����ֱͨ�ʣ�
��(������������������������Ͷ�뵽�����Ĺ�����δ�����ֹ������IJ�Ʒ̨��)/�ù��������������������������ɵIJ�Ʒ��Ʒ̨��
�Բ����ж�ֱͨ��Ʒ����ʱ��һ��Ҫ�ֹ�������������������A������ֻ���жϸò�Ʒ���к���A������ע���ǹ����������Dz��ߣ������� �����м����ߣ����ܸò�Ʒ���к�������δ���ֲ���������ǰ���IJ����������ֲ��������Ǹ��м����ߵķ�ֱͨƷ���������������Ƿ������˲��������в�����Ϊ��ֱͨƷ����ʹ�ò�Ʒ���к������������������ֹ����������Ըôε�������Ӱ�쵽ֱ̨ͨ���ļ��㡣
ֱͨ�ʲ����ڿ�ʱ�ε�����.ֻҪ�������ڹ����������ֹ�����������¼ΪֱͨƷ��û�в����ͼ�¼ΪֱͨƷ��Ȼ��������ʱ�Ρ�
�ù��������IJ�Ʒһ������ֱͨƷ
FQC����Ϊ�����������˵IJ�Ʒһ������ֱͨƷ */ #endregion
//if (flag == "Y" && iMoNGStart == 0
// && IDIsInRejectCountByMo(product.NowSimulationReport.RCARD,product.NowSimulationReport.MOCODE)==0
// && product.NowSimulationReport.NGTIMES == 0)
//{
// moAllGoodQty = Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE);
//}
} } else if (product.NowSimulation.PRODUCTSTATUS == "NG") { //reportRealtimeLineQty.NGTimes += 1;
//Ͷ�����ļ���
//��������TS�����Ҳ�Ʒǰһ��״̬�����ڵ�NG״̬����
//����ǰһ��Action�����ڵ�Action����ͬһ������
//�ɼ�NG��Ͷ����Ӧ�ü���
//����ֱ�Ӳɼ�NG����Ͷ������bug
//Eric ���м�Ͷ�빤��Ͷ���IJ�������Ʒ���Dz���Ʒ,����ΪͶ�����ļ���.�����ڼ���.
ngtimes = 1; if (product.NowSimulation.OPCODE == product.LastSimulation.OPCODE && (product.LastSimulation.LACTION == ActionType.DataCollectAction_GOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_SMTGOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_OutLineGood || product.LastSimulation.LACTION == ActionType.DataCollectAction_OQCPass) ) { if (flag == "Y" || midOP)//�Ƿ�Ϊ�����������м����㹤��
{ //��ǰվ�й�����,����ǰһ�β���״̬��GOOD�Ż�������
qty = Convert.ToInt32(-1 * product.NowSimulation.IDMERGERULE); if(product.NowSimulation != null) { //iNGStart = tSFacade.QueryTSCountByLine(
// product.NowSimulationReport.RCARD
// ,product.NowSimulationReport.SSCODE
// ,Convert.ToInt32(product.NowSimulationReport.RCARDSEQ));
//iMoNGStart = tSFacade.QueryTSCountByMo(
// product.NowSimulation.RCARD
// ,product.NowSimulation.MOCODE);
}
//ֱͨ������
//if ((IDIsInRejectCount(product.NowSimulationReport.RCARD,product.NowSimulationReport.SSCODE)==0)
// && iNGStart == 0)//rejectlist
//{
// allqty = Convert.ToInt32(-1 * product.NowSimulation.IDMERGERULE);
//}
//����ֱ̨ͨ��
#region �йز�����Ͷ�����������ʡ�ֱͨ�ʵIJ���˵����
/*3. ����ֱͨ�ʣ�
��(������������������������Ͷ�뵽�����Ĺ�����δ�����ֹ������IJ�Ʒ̨��)/�ù��������������������������ɵIJ�Ʒ��Ʒ̨��
�Բ����ж�ֱͨ��Ʒ����ʱ��һ��Ҫ�ֹ�������������������A������ֻ���жϸò�Ʒ���к���A������ע���ǹ����������Dz��ߣ������� �����м����ߣ����ܸò�Ʒ���к�������δ���ֲ���������ǰ���IJ����������ֲ��������Ǹ��м����ߵķ�ֱͨƷ���������������Ƿ������˲��������в�����Ϊ��ֱͨƷ����ʹ�ò�Ʒ���к������������������ֹ����������Ըôε�������Ӱ�쵽ֱ̨ͨ���ļ��㡣
ֱͨ�ʲ����ڿ�ʱ�ε�����.ֻҪ�������ڹ����������ֹ�����������¼ΪֱͨƷ��û�в����ͼ�¼ΪֱͨƷ��Ȼ��������ʱ�Ρ�
�ù��������IJ�Ʒһ������ֱͨƷ
FQC����Ϊ�����������˵IJ�Ʒһ������ֱͨƷ */ #endregion
//if (flag == "Y" && iMoNGStart == 0
// && IDIsInRejectCountByMo(product.NowSimulationReport.RCARD, product.NowSimulationReport.MOCODE) == 0
// && product.NowSimulationReport.NGTIMES == 1)
//{
// moAllGoodQty = Convert.ToInt32(-1 * product.NowSimulation.IDMERGERULE);
//}
}
} } else if (product.NowSimulation.PRODUCTSTATUS == "REJECT") { if (product.NowSimulation.RESCODE == product.LastSimulation.RESCODE && (product.LastSimulation.LACTION == ActionType.DataCollectAction_GOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_SMTGOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_OutLineGood || product.LastSimulation.LACTION == ActionType.DataCollectAction_OQCPass) ) { if (flag == "Y" || midOP)//�Ƿ�Ϊ�����������м����㹤��
{ //reportRealtimeLineQty.OuputQty -= 1 * product.NowSimulation.IDMERGERULE;
if(product.NowSimulationReport != null) { //iNGStart = tSFacade.QueryTSCountByLine(
// product.NowSimulationReport.RCARD
// ,product.NowSimulationReport.SSCODE
// ,Convert.ToInt32(product.NowSimulationReport.RCARDSEQ));
//iMoNGStart = tSFacade.QueryTSCountByMo(
// product.NowSimulation.RCARD
// ,product.NowSimulation.MOCODE);
}
//ֱͨ������
qty = Convert.ToInt32(-1 * product.NowSimulation.IDMERGERULE); //if ((IDIsInRejectCount(product.NowSimulationReport.RCARD,product.NowSimulationReport.SSCODE)==1)
// && iNGStart == 0)
//{
// allqty = Convert.ToInt32( -1 * product.NowSimulation.IDMERGERULE);
//}
//����ֱ̨ͨ��
#region �йز�����Ͷ�����������ʡ�ֱͨ�ʵIJ���˵����
///<Comment>3. ����ֱͨ�ʣ�
///��(������������������������Ͷ�뵽�����Ĺ�����δ�����ֹ������IJ�Ʒ̨��)/�ù��������������������������ɵIJ�Ʒ��Ʒ̨��
///�Բ����ж�ֱͨ��Ʒ����ʱ��һ��Ҫ�ֹ�������������������A������ֻ���жϸò�Ʒ���к���A������ע���ǹ����������Dz��ߣ������� �����м����ߣ����ܸò�Ʒ���к�������δ���ֲ���������ǰ���IJ����������ֲ��������Ǹ��м����ߵķ�ֱͨƷ���������������Ƿ������˲��������в�����Ϊ��ֱͨƷ����ʹ�ò�Ʒ���к������������������ֹ����������Ըôε�������Ӱ�쵽ֱ̨ͨ���ļ��㡣
///ֱͨ�ʲ����ڿ�ʱ�ε�����.ֻҪ�������ڹ����������ֹ�����������¼ΪֱͨƷ��û�в����ͼ�¼ΪֱͨƷ��Ȼ��������ʱ�Ρ�
///�ù��������IJ�Ʒһ������ֱͨƷ
///FQC����Ϊ�����������˵IJ�Ʒһ������ֱͨƷ
///</Comment>
#endregion
//if (flag == "Y" && iMoNGStart == 0
// && IDIsInRejectCountByMo(product.NowSimulationReport.RCARD, product.NowSimulationReport.MOCODE) == 0
// && product.NowSimulationReport.NGTIMES == 1)
//{
// moAllGoodQty = Convert.ToInt32(-1 * product.NowSimulation.IDMERGERULE);
//}
}
} } #endregion
if(product.NowSimulationReport.LACTION == ActionType.DataCollectAction_GoMO) { moInputQty = Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE); }
//������������
//û�����֡��������빤��ʲô����������ʡϵͳ��Դ
if(ngtimes != 0 || qty != 0 || allqty != 0 || inputQty != 0 || moInputQty != 0 || moAllGoodQty != 0 || actionType == ActionType.DataCollectAction_OffMo/*���빤������*/) { //û������ʲô����������ʡϵͳ��Դ
if(ngtimes != 0 || qty != 0 || allqty != 0 || inputQty != 0 || moInputQty != 0 || moAllGoodQty != 0) { #region ��ȡ����ʵ��
#endregion
}
}
if(product.NowSimulationReport.LACTION == ActionType.DataCollectAction_OffMo || product.NowSimulationReport.LACTION == ActionType.DataCollectAction_GoMO || flag == "Y") { //�������¹�������������
//mOFacade.UpdateMOQty(product.NowSimulationReport.MOCODE
// ,product.NowSimulationReport.LACTION
// ,Convert.ToInt32(1 * product.NowSimulation.IDMERGERULE));
} } catch (Exception e) { messages.Add(new Message(e)); } return messages; }
//Ӧ����û�п��ǵ��������ع�������
//�����Ƿ��ڵ�ǰվ�Ѿ�����ͳ��
private bool CheckNeedCountInthisResoure(ProductInfo product) { if (product.NowSimulation.RESCODE == product.LastSimulation.RESCODE && product.NowSimulation.OPCODE == product.LastSimulation.OPCODE && ( product.LastSimulation.LACTION == ActionType.DataCollectAction_GOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_SMTGOOD || product.LastSimulation.LACTION == ActionType.DataCollectAction_OutLineGood || product.LastSimulation.LACTION == ActionType.DataCollectAction_CollectKeyParts || product.LastSimulation.LACTION == ActionType.DataCollectAction_CollectINNO || product.LastSimulation.LACTION == ActionType.DataCollectAction_IDTran || product.LastSimulation.LACTION == ActionType.DataCollectAction_Split ) ) return true; else return false; }
} /// <summary>
/// �ܵļ���
/// </summary>
///
[Serializable] public class WeekObject { public int Week; }
/// <summary>
///
/// </summary>
///
[Serializable] public struct ReportQtyHelper { public decimal OuputQty; public decimal AllGoodQty; public decimal MoAllGoodQty; public ReportQtyHelper( decimal ouputQty, decimal allGoodQty, decimal moAllGoodQty) { OuputQty = ouputQty ; AllGoodQty = allGoodQty ; MoAllGoodQty= moAllGoodQty ; } } }
|