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.
278 lines
12 KiB
278 lines
12 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Linq;
|
|
using System.Data.Linq;
|
|
using System.Xml.Linq;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Frame.DataCollect;
|
|
using ICSSoft.Frame.Helper;
|
|
|
|
namespace ICSSoft.Frame.DataConnect.Action
|
|
{
|
|
/// <summary>
|
|
/// ActionUndoNG 的摘要说明。
|
|
/// </summary>
|
|
public class ActionUndoNG
|
|
{
|
|
private FramDataContext _domainDataProvider = null;
|
|
|
|
public ActionUndoNG(FramDataContext domainDataProvider)
|
|
{
|
|
this._domainDataProvider = domainDataProvider;
|
|
}
|
|
|
|
public FramDataContext DataProvider
|
|
{
|
|
get
|
|
{
|
|
return _domainDataProvider;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 采集NG后,可以再次测试采集,这里做自动Undo
|
|
/// </summary>
|
|
public Messages UndoNG(ActionEventArgs actionEventArgs)
|
|
{
|
|
Messages msg = new Messages();
|
|
// 是否配置需要Undo
|
|
if (System.Configuration.ConfigurationSettings.AppSettings["UndoNG"] != "1")
|
|
return msg;
|
|
//bool bNeedUndo = false;
|
|
|
|
//object objTmp;
|
|
//if (actionEventArgs.ProductInfo != null && actionEventArgs.ProductInfo.LastSimulation != null)
|
|
//{
|
|
// // 上次采NG的才可以Undo
|
|
// if (actionEventArgs.ProductInfo.LastSimulation.PRODUCTSTATUS == ProductStatus.NG)
|
|
// {
|
|
// // 产品是否还在本OP
|
|
// objTmp = modelFacade.GetOperation2Resource(actionEventArgs.ProductInfo.LastSimulation.OPCODE, actionEventArgs.ResourceCode);
|
|
// if (objTmp == null)
|
|
// return msg;
|
|
// // 是否已在做维修
|
|
// ts = (BenQGuru.eMES.Domain.TS.TS)tsFacade.GetCardLastTSRecord(actionEventArgs.ProductInfo.LastSimulation.RCARD);
|
|
// if (ts == null || ts.TSStatus != TSStatus.TSStatus_New)
|
|
// {
|
|
// return msg;
|
|
// }
|
|
// bNeedUndo = true;
|
|
// }
|
|
//}
|
|
//if (bNeedUndo == false)
|
|
// return msg;
|
|
//// 开始Undo
|
|
//// 查询ICSONWIP
|
|
//ICSSimulation simulation = actionEventArgs.ProductInfo.LastSimulation;
|
|
//string strSql = "SELECT * FROM ICSONWIP WHERE RCARD='" + simulation.RCARD + "' AND MOCODE='" + simulation.MOCODE + "' ORDER BY RCARDSEQ ";
|
|
//var objsWip = this._domainDataProvider.ExecuteQuery<ICSONWIP>(strSql).ToList();
|
|
//if (objsWip == null || objsWip.Count < 2)
|
|
// return msg;
|
|
//ICSONWIP wip = (ICSONWIP)objsWip[objsWip.Count - 1];
|
|
|
|
//DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
|
|
|
|
|
|
//#region 维修不良代码
|
|
////if (System.Configuration.ConfigurationSettings.AppSettings["UndoNGUndoReport"] == "1")
|
|
////{
|
|
//// // 查询TBLTSERRORCODE
|
|
//// strSql = "SELECT * FROM TBLTSERRORCODE WHERE TSID='" + ts.TSId + "' ";
|
|
//// object[] objsErrorCode = this.DataProvider.CustomQuery(typeof(BenQGuru.eMES.Domain.TS.TSErrorCode), new SQLCondition(strSql));
|
|
//// string strErrorCodeList = string.Empty;
|
|
//// if (objsErrorCode != null)
|
|
//// {
|
|
//// // 更新TBLRPTRESECG
|
|
//// for (int i = 0; i < objsErrorCode.Length; i++)
|
|
//// {
|
|
//// BenQGuru.eMES.Domain.TS.TSErrorCode errorCode = (BenQGuru.eMES.Domain.TS.TSErrorCode)objsErrorCode[i];
|
|
//// strErrorCodeList = strErrorCodeList + errorCode.ErrorCodeGroup + ":" + errorCode.ErrorCode + ";";
|
|
//// }
|
|
//// }
|
|
|
|
//// UndoNGReport(simulation, wip, true, strErrorCodeList, (ICSONWIP)objsWip[objsWip.Count - 2]);
|
|
////}
|
|
//#endregion
|
|
|
|
//// 更新ICSSimulation
|
|
//UndoNGSimulation(simulation, true, (ICSONWIP)objsWip[objsWip.Count - 2]);
|
|
|
|
|
|
//// 如果上次采集是GOOD->NG,这次采GOOD,那还需要Undo再上次的GOOD
|
|
//wip = (ICSONWIP)objsWip[objsWip.Count - 2];
|
|
//if (wip.ACTION == ActionType.DataCollectAction_GOOD
|
|
// && wip.OPCODE == simulation.OPCODE)
|
|
//{
|
|
// if (System.Configuration.ConfigurationSettings.AppSettings["UndoNGUndoReport"] == "1")
|
|
// {
|
|
// // 更新报表
|
|
// UndoNGReport(simulation, wip, false, string.Empty, (ICSONWIP)objsWip[objsWip.Count - 3]);
|
|
// }
|
|
// // 更新ICSSimulation
|
|
// UndoNGSimulation(simulation, false, (ICSONWIP)objsWip[objsWip.Count - 3]);
|
|
|
|
//}
|
|
|
|
//ActionOnLineHelper onlineHelper = new ActionOnLineHelper(this.DataProvider);
|
|
//Messages msgTmp = onlineHelper.GetIDInfo(simulation.RCARD);
|
|
//actionEventArgs.ProductInfo = (ProductInfo)msgTmp.GetData().Values[0];
|
|
|
|
return msg;
|
|
}
|
|
/* add by andy
|
|
|
|
|
|
/// <summary>
|
|
/// Undo时更新报表数据
|
|
/// </summary>
|
|
private void UndoNGReport(ICSSimulation simulation, ICSONWIP wip, bool isNG, string errorCodeList, ICSONWIP prevWip)
|
|
{
|
|
// 更新TBLRPTHISOPQTY
|
|
string qtyFlag = "N";
|
|
object objTmp = reportFacade.GetReportHistoryOPQty(wip.MODELCODE, wip.SHIFTDAY, wip.MOCODE, wip.TPCODE, wip.SSCODE, wip.SEGCODE, wip.ITEMCODE, wip.SHIFTCODE, wip.OPCODE, wip.RESCODE, "N");
|
|
if (objTmp == null)
|
|
{
|
|
objTmp = reportFacade.GetReportHistoryOPQty(wip.MODELCODE, wip.SHIFTDAY, wip.MOCODE, wip.TPCODE, wip.SSCODE, wip.SEGCODE, wip.ITEMCODE, wip.SHIFTCODE, wip.OPCODE, wip.RESCODE, "Y");
|
|
qtyFlag = "Y";
|
|
}
|
|
if (objTmp != null)
|
|
{
|
|
BenQGuru.eMES.Domain.Report.ReportHistoryOPQty hisQty = (BenQGuru.eMES.Domain.Report.ReportHistoryOPQty)objTmp;
|
|
// 如果上次是NG
|
|
if (isNG == true)
|
|
{
|
|
// NG次数减1
|
|
hisQty.NGTimes = hisQty.NGTimes - 1 * simulation.IDMERGERULE;
|
|
// 更新不良代码列表
|
|
if (hisQty.ErrorGroup2Err.Length >= errorCodeList.Length && errorCodeList != string.Empty)
|
|
{
|
|
hisQty.ErrorGroup2Err = hisQty.ErrorGroup2Err.Substring(0, hisQty.ErrorGroup2Err.Length - errorCodeList.Length);
|
|
}
|
|
}
|
|
else // 如果上次是GOOD
|
|
{
|
|
// 如果是Undo GOOD,那OutputQty要不要减 1 ?
|
|
// 由于Undo GOOD之前一定做过Undo NG,所以OutputQty不用减 1
|
|
// 也就是这个OP上最后采集的结果是NG,本来就没有记OutputQty
|
|
//hisQty.OuputQty = hisQty.OuputQty - 1;
|
|
}
|
|
if (prevWip.ACTION == ActionType.DataCollectAction_GoMO)
|
|
{
|
|
// 减去OP采集数
|
|
hisQty.EAttribute2 = hisQty.EAttribute2 - 1 * simulation.IDMERGERULE;
|
|
}
|
|
this.DataProvider.Update(hisQty);
|
|
}
|
|
// 更新tblrptreallineecqty
|
|
if (isNG == true)
|
|
{
|
|
string[] errorCodes = errorCodeList.Split(';');
|
|
for (int i = 0; i < errorCodes.Length; i++)
|
|
{
|
|
if (errorCodes[i] == string.Empty)
|
|
continue;
|
|
string[] errorCode = errorCodes[i].Split(':');
|
|
BenQGuru.eMES.Domain.Report.ReportRealtimeLineErrorCodeQty rptErrorCode =
|
|
(BenQGuru.eMES.Domain.Report.ReportRealtimeLineErrorCodeQty)reportFacade.GetReportRealtimeLineErrorCodeQty(wip.MODELCODE, wip.SHIFTDAY, wip.MOCODE, wip.TPCODE, wip.SSCODE, wip.SEGCODE, wip.ITEMCODE, wip.SHIFTCODE, errorCode[1], errorCode[0]);
|
|
if (rptErrorCode != null)
|
|
{
|
|
if (rptErrorCode.ErrorCodeTimes <= 1)
|
|
reportFacade.DeleteReportRealtimeLineErrorCodeQty(rptErrorCode);
|
|
else
|
|
{
|
|
string strSql = "UPDATE ICSRPTREALLINEECQTY SET ECTIMES=ECTIMES-1 WHERE MODELCODE='" + wip.MODELCODE + "' AND SHIFTDAY=" + wip.SHIFTDAY.ToString() +
|
|
" AND MOCODE='" + wip.MOCODE + "' AND TPCODE='" + wip.TPCODE + "' AND SSCODE='" + wip.SSCODE + "' AND SEGCODE='" + wip.SEGCODE + "' AND ITEMCODE='" + wip.ITEMCODE + "' AND SHIFTCODE='" + wip.SHIFTCODE + "' " +
|
|
" AND ECODE='" + errorCode[1] + "' AND ECGCODE='" + errorCode[0] + "' ";
|
|
//this.DataProvider.CustomExecute(new SQLCondition(strSql));
|
|
strSql = string.Format(strSql);
|
|
this._domainDataProvider.ExecuteCommand(strSql);
|
|
this._domainDataProvider.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 更新TBLRPTREALLINEQTY
|
|
string updateField = string.Empty;
|
|
// 如果上次是NG
|
|
if (isNG == true)
|
|
{
|
|
// NG次数减1
|
|
updateField = "NGTimes=NGTimes-" + (1 * simulation.IDMERGERULE).ToString();
|
|
}
|
|
else
|
|
{
|
|
// 如果完工,则更新完工数量
|
|
if (FormatHelper.StringToBoolean(simulation.ISCOM) == true)
|
|
{
|
|
updateField = "OutputQty=OutputQty-" + (1 * simulation.IDMERGERULE).ToString();
|
|
if (simulation.NGTIMES == 0)
|
|
{
|
|
if (reworkFacade.GetRejectCountByMO(simulation.RCARD, simulation.MOCODE) == 0)
|
|
{
|
|
updateField += "AllGoodQty=AllGoodQty-" + (1 * simulation.IDMERGERULE).ToString();
|
|
}
|
|
}
|
|
// 更新工单产出
|
|
string strSql = "UPDATE ICSMO SET MOACTQTY=MOACTQTY-" + (1 * simulation.IDMERGERULE).ToString() + " WHERE MOCODE='" + simulation.MOCODE + "' ";
|
|
//this.DataProvider.CustomExecute(new SQLCondition(strSql));
|
|
strSql = string.Format(strSql);
|
|
this._domainDataProvider.ExecuteCommand(strSql);
|
|
this._domainDataProvider.SubmitChanges();
|
|
}
|
|
}
|
|
if (updateField != string.Empty)
|
|
{
|
|
string strSql = "UPDATE ICSRPTREALLINEQTY SET " + updateField + " WHERE MODELCODE='" + wip.MODELCODE + "' AND SHIFTDAY=" + wip.SHIFTDAY.ToString() +
|
|
" AND MOCODE='" + wip.MOCODE + "' AND TPCODE='" + wip.TPCODE + "' AND SSCODE='" + wip.SSCODE + "' AND SEGCODE='" + wip.SEGCODE + "' AND ITEMCODE='" + wip.ITEMCODE + "' AND SHIFTCODE='" + wip.SHIFTCODE + "' " +
|
|
" AND QTYFLAG='" + qtyFlag + "' ";
|
|
//this.DataProvider.CustomExecute(new SQLCondition(strSql));
|
|
strSql = string.Format(strSql);
|
|
this._domainDataProvider.ExecuteCommand(strSql);
|
|
this._domainDataProvider.SubmitChanges();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Undo时更新ICSSimulation数据
|
|
/// </summary>
|
|
private void UndoNGSimulation(ICSSimulation simulation, bool isNG, ICSONWIP wip)
|
|
{
|
|
// 更新ICSSimulation
|
|
DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
|
|
string lastAction = wip.ACTION;
|
|
simulation.LACTION = lastAction;
|
|
string[] actionList = simulation.ACTIONLIST.Split(';');
|
|
simulation.ACTIONLIST = string.Join(";", actionList, 0, actionList.Length - 2) + ";";
|
|
simulation.PRODUCTSTATUS = wip.ACTIONRESULT;
|
|
if (isNG == true)
|
|
simulation.NGTIMES = simulation.NGTIMES - 1;
|
|
simulation.ISCOM = FormatHelper.BooleanToString(false);
|
|
//simulation.RunningCardSequence = wip.RunningCardSequence; // 保留测试信息
|
|
dataCollectFacade.UpdateSimulation(simulation);
|
|
// 更新SimulationReport
|
|
ICSSimulationReport simulationReport = (ICSSimulationReport)dataCollectFacade.GetLastSimulationReport(simulation.RCARD);
|
|
simulationReport.LACTION = lastAction;
|
|
simulationReport.PRODUCTSTATUS = wip.ACTIONRESULT;
|
|
if (isNG == true)
|
|
simulationReport.NGTIMES = simulationReport.NGTIMES - 1;
|
|
simulationReport.ISCOM = FormatHelper.BooleanToString(false);
|
|
//simulationReport.RunningCardSequence = wip.RunningCardSequence; // 保留测试信息
|
|
dataCollectFacade.UpdateSimulationReport(simulationReport);
|
|
}
|
|
/// <summary>
|
|
/// 更新Undo的WIP
|
|
/// </summary>
|
|
/// <param name="wip"></param>
|
|
//private void UpdateUndoWIP(ICSONWIP wip)
|
|
//{
|
|
// string strSql = "INSERT INTO tblOnWIPUndo SELECT * FROM tblOnWIP WHERE MOCode='" + wip.MOCode + "' AND RCard='" + wip.RunningCard + "' AND RCardSeq=" + wip.RunningCardSequence.ToString();
|
|
// this.DataProvider.CustomExecute(new SQLCondition(strSql));
|
|
// this.DataProvider.Delete(wip);
|
|
//}
|
|
|
|
|
|
|
|
*/
|
|
}
|
|
}
|